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!
Solved! Go to Solution.
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)
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)
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
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?
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 🙂
Stay up tp date on the latest blogs and activities in the community News & Announcements.
Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
User | Count |
---|---|
203 | |
171 | |
63 | |
32 | |
31 |
User | Count |
---|---|
338 | |
271 | |
105 | |
71 | |
56 |