Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Pages - Power Apps Portals
Answered

webform javascript validation

(0) ShareShare
ReportReport
Posted on by 84

Hi!

I'm trying to validate a field in my webform step where it checks if the email ends with the domain of their website, but whatever i try it doesn't work.
Here's my code:

 

if (window.jQuery) {
 (function ($) {
 if (typeof (webFormClientValidate) != 'undefined') {
 var originalValidationFunction = webFormClientValidate;
 if (originalValidationFunction && typeof (originalValidationFunction) == "function") {
 webFormClientValidate = function() {
 originalValidationFunction.apply(this, arguments);
 var email = $("#cr36b_epasts.text").val();
 var domain = $("#cr36b_domeins.text").val();
 if (email.endsWith(domain)) {
 return true;
 } else {
 return false;
 alert("email has to end with your domain.");
 }
 };
 }
 }
 }(window.jQuery));
}

 

I've inserted this js in Webform->webform step->form options->custom js. Would appreciate help with this, even if it is some other way of validation that isnt JS.
I would also like to validate the domain input field to make sure that it isnt any generic email websites such as gmail, yahoo, Hotmail etc.

  • KD203 Profile Picture
    84 on at
    Re: webform javascript validation

    Worked perfectly, thank you!

  • Verified answer
    justinburch Profile Picture
    Microsoft Employee on at
    Re: webform javascript validation

    Hi @KD203,

    These kinds of bugs seem to occur too often. Looks like the product is not providing the right files currently - webFormClientValidate isn't an available function, but entityFormClientValidate is. Unfortunately, entityFormClientValidate isn't called, so.. we need to make our own webFormClientValidate function. Note that the "alert" function should come before your return statement.

    if (window.jQuery) {
     (function ($) {
     webFormClientValidate = function() {
     var email = $("#cr36b_epasts.text").val();
     var domain = $("#cr36b_domeins.text").val();
     if (email.endsWith(domain)) {
     return true;
     } else {
     alert("email has to end with your domain.");
     return false;
     }
     };
     }(window.jQuery));
    }

     

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Pages

#1
Lucas001 Profile Picture

Lucas001 60 Super User 2025 Season 1

#2
Fubar Profile Picture

Fubar 55 Super User 2025 Season 1

#3
surya narayanan Profile Picture

surya narayanan 35