Scenario: We have Two Fields Email address and Confirm Email address if both values are not entered same then we need to through an error on page validator using jQuery
Step 1: Get the Schema name of Email Address and Confirm Email Address.
Step 2: Write jQuery as below.
$(document).ready(function () {
//Create pin code validator
var confirmEmail = document.createElement('span');
//setup validator property and associated field
confirmEmail.style.display = "none";
confirmEmail.id = "new_confirmemailaddress_Validator";
confirmEmail.controltovalidate = "new_confirmemailaddress"; // single line text (type as email)
confirmEmail.evaluationfunction = function () {
var email = $("#new_emailaddress").val(); // getting the email address value and declaring variable as email
var confirmEmailAddress = $("#new_confirmemailaddress").val(); // getting the comfirm email address value and declaring as confirmEmailAddress
if (confirmEmailAddress !== null && confirmEmailAddress !== "" && confirmEmailAddress !== undefined) { // Chcek condition
if (email === confirmEmailAddress) { // Check subcondition
return true;
}
else {
//setup custom validation message
this.errormessage = "<a href='#new_confirmemailaddress_label'>Your Email Address doesn't match with Confirm Email Address.</a>";
return false;
}
}
else {
return true;
}
};
// Add the validator to the page validators array:
Page_Validators.push(confirmEmail);
});
Step 3: Paste the code in respective Basic / Entity Form and save the records shown in below image.
Step 4: Clear the Portal Server Side Cache.
Step 5: Now Check your functionality is working as expected or not.
Hope it helps to you guys, if you struck anywhere add your comments in comment box section will help you out to fix the issue.