web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / General Form Validatio...
Power Pages
Unanswered

General Form Validation - entityFormClientValidate Function

(0) ShareShare
ReportReport
Posted on by 31

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));
}

 

 

 

Categories:
I have the same question (0)
  • Fubar Profile Picture
    8,338 Super User 2025 Season 2 on at

    General, debugging

    • if all you do is return False does it stop? (i.e. don't validate anything - just use the MST provided code and return false)
    • If Yes, then issue is in your custom validation
    • If No, then check if the "entityFormClientValidate" object exists

     

    (just a side note: as a general rule, always try and use internal identifiers rather than Text label values for comparisons - otherwise when someone later on decides to rename a label your code breaks)

  • Nerd_Gorilla1 Profile Picture
    31 on at

    Ok I was able to get it working using Microsoft's Additional client-side field validation code snippet instead of the General validation snippet. As someone who is new to JS and form validation, can someone explain when I would use the General validation code snippet instead? What is the difference between the two?

  • Fubar Profile Picture
    8,338 Super User 2025 Season 2 on at

    In the old days you would use the "Page_Validators" for Entity/Basic Forms, and the "entityFormClientValidate" for Web/Advanced/Multi-Step Forms (has had various names over the years).  The "Page_Validators" approach allows you to format the error messages as thought they are out of the box errors.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Pages

#1
Jerry-IN Profile Picture

Jerry-IN 71

#2
Fubar Profile Picture

Fubar 62 Super User 2025 Season 2

#3
sannavajjala87 Profile Picture

sannavajjala87 31

Last 30 days Overall leaderboard