Forum Discussion
Jayshree_Kedare
Jan 16, 2024Copper Contributor
Validation for form submission in Powerapps
I have created a form whereby I have defined certain fields are mandatory, I need to build a validation whereby if user hits the submit button it should not get submitted but rather prompt to fill th...
Jon_Lake
Jan 16, 2024Brass Contributor
Hi Jayshree_Kedare , you can use a hidden field for each mandatory field, which is populated with an integer value using an IF statement, e.g. if there is data in the field the value is 1, or of there is no data the value is 0.
You then wrap the patch/action script under the button in an IF statement, asking if the sum of the hidden fields equals the count of the mandatory fields. If it does then the action can complete. If it is less then the user is notified with a message, the background of the field where data is missing can be coloured (in red for example) and the focus can be set on the first missing field.
I've used this technique a number of times.
- Jayshree_KedareJan 16, 2024Copper Contributor
Hi Jon_Lake , Thank you for the suggestion, I will try this.