I am trying to add a basic Additional Client Side Field Validation to my Entity Form but it's not working.
The Validation should only check if 2 text field are equal (the out of the box email address field and a custom email field):
if (window.jQuery) {
(function ($) {
if (typeof (Page_Validators) == 'undefined') return;
// Create new validator
var newValidator = document.createElement('span');
newValidator.style.display = "none";
newValidator.id = "confirmemailValidator";
newValidator.controltovalidate = "confirmemail";
newValidator.errormessage = "Email address is not equal to the confirmation email address.";
newValidator.validationGroup = ""; // Set this if you have set ValidationGroup on the form
newValidator.initialvalue = "";
newValidator.evaluationfunction = function () {
var emailaddress = $("#emailaddress1").val();
var confirmemailaddress = $("#confirmemail").val();
if (emailaddress !== confirmemailaddress) {
alert("h");
return false;
} else {
return true;
}
};
// Add the new validator to the page validators array:
Page_Validators.push(newValidator);
// Wire-up the click event handler of the validation summary link
$(document).ready(function () {
$("a[href='#confirmemail_label']").on("click", function () { scrollToAndFocus('confirmemail_label','confirmemail'); });
});
}(window.jQuery));
}
I added the above javascript to the 'Custom Javascript' field on the portal Entity Form record.
Also, I don't know if this is totally unrelated, but in the Custom javascript documentation: https://community.adxstudio.com/products/adxstudio-portals/documentation/configuration-guide/web-forms/web-form-steps/custom-javascript/ it says that the validation should be added at the bottom of the page, before the closing tags; but when debugging, I noticed that the code block is actually being added somewhere on the top of the page.
This should be pretty straight forward so I'm not sure where I'm getting it wrong.
*This post is locked for comments