cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
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
Highlighted
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

Highlighted

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?

Highlighted

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

 

Highlighted
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.

Highlighted

@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))

 

Highlighted

 

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?

Highlighted

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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (9,746)