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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / webform javascript val...
Power Pages
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.

Categories:
I have the same question (0)
  • Verified answer
    justinburch Profile Picture
    Microsoft Employee on at

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

     

  • KD203 Profile Picture
    84 on at

    Worked perfectly, thank you!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
Mohsin Ali Profile Picture

Mohsin Ali 33

#2
sannavajjala87 Profile Picture

sannavajjala87 28 Super User 2026 Season 2

#3
11manish Profile Picture

11manish 22 Super User 2026 Season 2

Last 30 days Overall leaderboard