All,
I'm using Microsoft's documentation located here to write some form validation rules in my portal. Here is the sample code that Microsoft offers. Notice where they have comments to insert you custom validation.
if (window.jQuery) {
(function ($) {
if (typeof (entityFormClientValidate) != 'undefined') {
var originalValidationFunction = entityFormClientValidate;
if (originalValidationFunction && typeof (originalValidationFunction) == "function") {
entityFormClientValidate = function() {
originalValidationFunction.apply(this, arguments);
// do your custom validation here
// return false; // to prevent the form submit you need to return false
// end custom validation.
return true;
};
}
}
}(window.jQuery));
}
Now, below is my code with custom validation rules applied. After saving these in Form Steps >Form Options, it still doesn't seem to work. I'm able to still advance to the next screen/form step when the field "BIL Category" is set to one of the values. Any ideas?
if (window.jQuery) {
(function ($) {
if (typeof (entityFormClientValidate) != 'undefined') {
var originalValidationFunction = entityFormClientValidate;
if (originalValidationFunction && typeof (originalValidationFunction) == "function") {
entityFormClientValidate = function() {
originalValidationFunction.apply(this, arguments);
// Begin custom validation.
var categoryValue = $('#cr92d_bilcategory').find("option:selected").text();
if (categoryValue !== 'Emerging Contaminants ' && categoryValue !== 'Lead Service Line ' && categoryValue !== 'Supplemental') {
return false;}
// End custom validation.
return true;
};
}
}
}(window.jQuery));
}