cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
er
Level: Powered On

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
PowerApps Staff CarlosFigueira
PowerApps Staff

Re: Validate phone number/email

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

5 REPLIES 5
PowerApps Staff CarlosFigueira
PowerApps Staff

Re: Validate phone number/email

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

er
Level: Powered On

Re: Validate phone number/email

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?

UNILIEN
Level: Powered On

Re: Validate phone number/email

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

 

ravi_anand
Level: Powered On

Re: Validate phone number/email

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.

Super User
Super User

Re: Validate phone number/email

@ravi_anand

 

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

 

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (5,707)