cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
er
Advocate IV
Advocate IV

Validate phone number/email

I could not find exactly what I was looking for in previous posts, so I decided to create a new one.

 

Is there a way to make sure the text field for users to input their email contains the "@" sign? Or that the phone number field has at least ten characters?

 

Any help would be much appreciated!

1 ACCEPTED SOLUTION

Accepted Solutions
CarlosFigueira
Power Apps
Power Apps

You can use the IsMatch function, which should do what you need. For example, if you want to highlight a text input that should contain an e-mail, you can use the following expression in its BorderColor property.

If(IsMatch(TextInput1.Text, Match.Email), Color.Blue, Color.Red)

The function IsMatch can be used for a lot of scenarios, but for simpler cases, like in your second example (minimum length), you can use the Len function, which returns the number of characters in a string. In an example similar to the one above, you could set the border color of the text input that is used to enter the telephone number to the expression below:

If(Len(TextInput2.Text) < 10, Color.Red, Color.Blue)

 

View solution in original post

7 REPLIES 7
CarlosFigueira
Power Apps
Power Apps

You can use the IsMatch function, which should do what you need. For example, if you want to highlight a text input that should contain an e-mail, you can use the following expression in its BorderColor property.

If(IsMatch(TextInput1.Text, Match.Email), Color.Blue, Color.Red)

The function IsMatch can be used for a lot of scenarios, but for simpler cases, like in your second example (minimum length), you can use the Len function, which returns the number of characters in a string. In an example similar to the one above, you could set the border color of the text input that is used to enter the telephone number to the expression below:

If(Len(TextInput2.Text) < 10, Color.Red, Color.Blue)

 

View solution in original post

That worked perfectly, thank you! 

 

Is there a way that I can add this to the "OnChange" so that it doesn't come up red until they insert something incorrectly?

Hello,

 

I tried it on my form and it doesn't work

 

If(IsMatch(DataCardValue12.Text;Match.Email);Color.Blue;Color.Red)

 

Can you help me ?

 

Helene

 

Anonymous
Not applicable

This answer is working well. but could not stop form to get submit and update data back to data source. My email input box isinside datacard? any help would be highly apprecieted.

@Anonymous

 

To validate your data on form submission, change the formula for your submit button from SubmitForm(EditForm1) to:

 

If(IsMatch(TextInput1.Text, Match.Email), SubmitForm(EditForm1))

 

 

If(Len(TextInput2.Text) < 10, Color.Red, Color.Blue)

 This formula can't be used for phone number as it checks the length of the string doesn't matter if its a number or a letter.

 

If they type "TELEVISION" in the phone number textbox it will still validated it right?

Anonymous
Not applicable

You might be able to use a combination of the len and IsNumeric functions to make sure it's a number and that it's at least 10 numbers long. I haven't tested it though so can't say for sure 🙂

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,352)