Sitemap

Form Validation in Power Apps — Part 1

4 min readJun 27, 2020

In this blog, we are going to see how we can do the implementation of form validation in Power Apps.

Let get started, I have designed the Sign-Up page which has the following fields:

  1. Email
  2. Password and Confirm Password
  3. Phone Number

Following is Screenshot of my Sign-Up Page build in PowerApp:

Press enter or click to view image in full size

Following is App Controls Structure which I have followed to Create Sign Up Form:

Press enter or click to view image in full size

I have used “ErrorText” which is HTML Label Control for Logging all the Validation Errors.

Press enter or click to view image in full size

Now, we will set the Properties on ErrorText control to display the error on the Form for Each Input

Following is an explanation of each validation which I have used in this Power Apps:

Email Validation

  1. Not(IsBlank(‘ControlName’)) — It will validate if Field is blank or not.
  2. IsMatch(‘ControlName’.Text , Match.Email) — It will validate the email format and return false if the user enters invalid Email Address.
  3. Code:
If(Not(IsBlank('Email Address')),
If(
IsMatch(
'Email Address'.Text,
Match.Email
),
"",
"Please Enter Valid Email <br>"
),
"Please Enter Email <br>"
)

Password and Confirm Password Validation

  1. Not(IsBlank(‘ControlName’)) — It will validate if Field is blank or not.
  2. ‘Confirm Password’.Text = Password.Text — It will validate if the password and confirm password are the same or not. It will return false if both password will not match.
  3. Code:
If(
Not(IsBlank('Confirm Password')) && Not(IsBlank('Password')),
If(
'Confirm Password'.Text = Password.Text,
"",
"Please enter Same Password <br>"
),
"Please Enter Passwords <br>"
)

Phone Number Validation

  1. Not(IsBlank(‘ControlName’)) — It will validate if Field is blank or not.
  2. IsMatch(‘Control’.Text, “Your country Phone Validation ReGex”) — It will validate if the entered phone number is valid or not using ReGex.
  3. I have used phone number validation ReGex for India — “^[6–9]\d{9}$”
  4. Following is an explanation of my ReGex:
^     #Match the beginning of the string[6-9] #Match a 6, 7, 8 or 9\d    #Match a digit (0-9 and anything else that is a "digit" in the regex engine){9}  #Repeat the previous "\d" 9 times (9 digits)$    #Match the end of the string

5. Code:

If(
Not(IsBlank('Phone Number')),
If(
IsMatch('Phone Number'.Text, "^[6-9]\d{9}$"),
"",
"Please enter Valid Phone No <br>"
),
"Please Enter Phone No. <br>"
)

Following is full code for Validation you need to paste in Formula bar of HtmlText Property:

If(Not(IsBlank('Email Address')),
If(
IsMatch(
'Email Address'.Text,
Match.Email
),
"",
"Please Enter Valid Email <br>"
),
"Please Enter Email <br>"
)&
If(
Not(IsBlank('Confirm Password')) && Not(IsBlank('Password')),
If(
'Confirm Password'.Text = Password.Text,
"",
"Please enter Same Password <br>"
),
"Please Enter Passwords <br>"
)&
If(
Not(IsBlank('Phone Number')),
If(
IsMatch('Phone Number'.Text, "^[6-9]\d{9}$"),
"",
"Please enter Valid Phone No <br>"
),
"Please Enter Phone No. <br>"
)

Result:

Blank Field Validation for each Fields — Email, Password, Confirm Password and Phone Number

Press enter or click to view image in full size

Email Format Validation

Press enter or click to view image in full size

Now, you can see after entering valid email error has gone

Press enter or click to view image in full size

Password and Confirm Password Match Validation

Press enter or click to view image in full size

Phone Number Format Validation Check

Press enter or click to view image in full size

After adding valid phone number error is gone

Press enter or click to view image in full size

Hope this helps, stay tuned for more blogs.

--

--

Amit Prajapati
Amit Prajapati

Written by Amit Prajapati

I am Technical Consultant from Mumbai, India. I like to contribute my knowledge to the community and good social cause.

No responses yet