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 / Custom Form Input Vali...
Power Pages
Answered

Custom Form Input Validation on a single field

(0) ShareShare
ReportReport
Posted on by 56

Hello,

 

I'm working on form validation. I was able a to add this to validators:

 

 

if (window.jQuery) {
 (function ($) {
 $(document).ready(function () {
 if (typeof (Page_Validators) == 'undefined') return;
 // Create new validator
 var newValidator = document.createElement('span');
 newValidator.style.display = "none";
 newValidator.id = "emailaddress1Validator";
 newValidator.controltovalidate = "emailaddress1";
 newValidator.errormessage = "<a href='#emailaddress1_label' referencecontrolid='emailaddress1 ' onclick='javascript&colon;scrollToAndFocus(\"emailaddress1 _label\",\" emailaddress1 \");return false;'>Email is a required field.</a>";
 newValidator.validationGroup = ""; // Set this if you have set ValidationGroup on the form
 newValidator.initialvalue = "";
 newValidator.evaluationfunction = function () {
 var contactMethod = $("#preferredcontactmethodcode").val();
 if (contactMethod != 2) return true; // check if contact method is not 'Email'.
 // only require email address if preferred contact method is email.
 var value = $("#emailaddress1").val();
 if (value == null || value == "") {
 return false;
 } else {
 return true;
 }
 };

 // Add the new validator to the page validators array:
 Page_Validators.push(newValidator);

 });
 }(window.jQuery));
}

 

 

But it only works when I manually trigger the validation by calling:

 

 

$("#field_id").change(function() {
 Page_ClientValidate();
});

 

 

but this will execute validation for the whole form.

So I have 2 questions:

1. How can I config the Page_Validators work automatically without trigger manually?

2. How can I just validate 1 particular field instead?

 

Thank you!

Categories:
I have the same question (0)
  • Verified answer
    EmadBeshai Profile Picture
    806 Moderator on at

    Hi @Hannz,

    Form validation is fired when you click next or submitting the form.

    There is no OOB configuration or jQuery code to fire the validation against one field.

    If you want to do the validation per field then you will build a custom validation plugin by using jQuery but unfortunately no OOB functionality supports your needs.

     

    Please mark this answer as accepted if that helped you, 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
Valantis Profile Picture

Valantis 58

#2
11manish Profile Picture

11manish 55

#3
Vish WR Profile Picture

Vish WR 29

Last 30 days Overall leaderboard