Skip to content
Home ยป Email Validation in Power Apps

Email Validation in Power Apps

This article demonstrates how to validate if email is not in correct format in Power Apps. It is must to have validation on data while inserting or editing records.

Lets see how to validate email, As you can see below screen we have selected one record from gallery.




If you take a look on email id of selected record, it is not in correct format as domain name and @ symbol is missing there in email.

Also, when you click on submit button, it does not validate the email because there is no email validation check applied on form.

 

Lets click on submit button to update the selected record and you can see record is updated successfully without validating the email id format.

Now to validate the format of email id, we will use IsMatch function which checks whether a given text string matches a pattern that can comprise ordinary characters, predefined patterns, or any regular expression.

Lets, select the error message label of email data card, in our case the name of error message control is ErrorMessage8ย  and data email data card name is Email_DataCard1 as shown below.

Now on the Text property of ErrorMessage8, just write the below code that will check if the email id is in valid email format or not using IsMatch function.

If(
DataCardValue7.Text <> "" || DataCardValue7.Text <> Blank(),
If(
IsMatch(
DataCardValue7.Text,
Match.Email
),
"",
"Invalid Email Id"
),
Parent.Error
)

Once you done with the above step. You can see an error message label, check the given email value and return an error message.

Lets verify the above code with valid email id format, and you can see this time it is not giving error.




Now, add a condition check on submit button, ifย  the email id is not in correct format then record should not be submitting.

For this, lets open the OnSelect property of submit button as shown below.

After that write code as given below.

If(
(ErrorMessage8.Text = "" || ErrorMessage8.Text = Blank()),
SubmitForm(Form1)
)

Now, when user will click on submit button record will be submitted only if email id is in correct format otherwise it will not let submit the record.

Loading

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.