Hello again Birgit RD,
I tried to reproduce your code adjusted to my scenario:
if(window.jQuery){
alert("jQuery exist");
(function($) {
$(document).ready(function() {
$('#InsertButton').on('click', function () {
alert("button has been clicked");
if (typeof (Page_Validators) == 'undefined') return;
alert("Page_Validators is defined");
// Create new validator
var newValidator = document.createElement('span');
newValidator.style.display = "none";
newValidator.id = "emailaddress1Validator";
newValidator.controltovalidate = "emailaddress1";
newValidator.validationGroup = ""; // Set this if you have set ValidationGroup on the form
newValidator.initialvalue = "";
newValidator.evaluationfunction = function () {
var retVal = true;
newValidator.errormessage = "";
var emailAddress = $('#emailaddress1').val();
if(emailAddress === null || emailAddress === ""){
alert("email is empty");
newValidator.errormessage = "Use must introduce a valid email address.";
retVal = false;
}
alert("evaluation finished");
return retVal;
};
// Add the new validator to the page validators array:
Page_Validators.push(newValidator);
})
});
}(window.jQuery));
}
My browser gives me the alerts "jQuery exist", "Page_Validators is defined" and then the record is submitted.
I ensure the email field is empty, and i dont even receive the alert "evaluation finished"
Just for the record, in your code:
newValidator.id = "commentvalidator"; => you are adding this id name in the code randomly right? there is not any CRM relation
newValidator.controltovalidate = "feb_password"; => this feb_password is your CRM field name or its the id of the element on the HTML code?
thanks in advance!