Announcements
Hi,
I would like to add jQuery validation plugin to validate fields in a webform step on entry.
1. Where to add? (header, webpage, webform step)
2. Where to add rules for a validation (webform step, webpage)
Thank you in advance.
Hi, the ideal place for you to add the validation will be Web Form Steps
You can also use Web Page but I wouldn't really recommend, I try normally to keep the JS code specific to the main component
for more info: https://docs.microsoft.com/en-us/powerapps/maker/portals/configure/add-custom-javascript
Thank you for the answer.
So to initializes jQuery validation plugin I have to add the following code to Web Form step?
is it correct?
Thank you
Hi, no you don't need to worry about initializing jQuery plugin
jQuery will be loaded automatically with your Portals, you can just add the validation code:
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'>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); // Wire-up the click event handler of the validation summary link $("a[href='#emailaddress1_label']").on("click", function () { scrollToAndFocus('emailaddress1_label','emailaddress1'); }); }); }(window.jQuery)); }
I think probably the first part I normally ignore "if (window.jQuery)...".. but that shouldn't be any problem either
Thank you. I am looking for a validation on an entry, not on a submit.
If it is "First Name" filed, rules for entry: no less then 2 letters, no symbols
and if user enters 3d letter or symbol, error shows up under field right away.
have you considered adding mask?: http://oliverrodrigues365.com/2020/04/15/power-apps-portals-adding-field-mask/
another option would be validation the content on the On Change event, and displaying an error message or something for the user to correct the data, you will still need the same validation on the form submit, so I still think you can consider the form validation
Thank you, Oliver.
Adding a mask is great idea! I will try this as well.
Ans found a solution how to use JQuery validation plugin.
I added some libraries, did some customization.
Thank you again.
PS:
Congratulation on your MVP
super thanks 😁😁😁
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.
Congratulations to our 2026 Super Users!
Congratulations to our 2025 community superstars!
These are the community rock stars!
Stay up to date on forum activity by subscribing.
rezarizvii 53
DP_Prabh 40
oliver.rodrigues 28 Most Valuable Professional