Forum Discussion

Jayshree_Kedare's avatar
Jayshree_Kedare
Copper Contributor
Jan 16, 2024

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 the blank fields. 

2 Replies

  • Jon_Lake's avatar
    Jon_Lake
    Brass 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.

Resources