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 / webform javascript val...
Power Pages
Unanswered

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

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