Hi,
I've been trying to add a custom JavaScript validation for one of my Portal Web Forms and I can't seem to get it to work.
I've tried both Additional Field Validation and General Client Side Validation from what's provided here but it just doesn't work : https://docs.microsoft.com/en-us/dynamics365/customer-engagement/portals/add-custom-javascript
Here's what I did for the General Client Side Validation:
if (window.jQuery) {
(function ($) {
$(document).ready(function () {
alert("In here 1");
if (typeof webFormClientValidate === "function") {
alert("In here 2");
var originalValidationFunction = webFormClientValidate;
if (originalValidationFunction && typeof originalValidationFunction === "function") {
alert("In here 3");
webFormClientValidate = function () {
originalValidationFunction.apply(this, arguments);
alert("In here 4");
var _allowSubmit = false;
var _selected = $("#WebResource_MyCustomPage").contents().find("input[type='checkbox']:checked");
if (_selected != null && _selected != undefined && _selected != "" && _selected.length > 0) {
alert("In here 5.1");
_allowSubmit = true;
}
else {
alert("In here 5.2");
_allowSubmit = false;
}
return _allowSubmit;
};
}
}
});
}(window.jQuery));
}
I just get the alert "In Here 1" when the web form step loads, but that's it. And yes I have Enable Validation Summary Links checked.
Does the latest version of the Portal have anything to do with it (considering Microsoft "fixes" stuff that's not broken from time to time)? The only workaround I can think of right now is to use a custom button using DOM injection and hide the default Next button.
Any help would be appreciated.
*This post is locked for comments
I have the same question (0)