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

Validate Phone number

Hi.. can anybody help me to validate phone number in us format while inputing

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Dual Super User III
Dual Super User III

Re: Validate Phone number

Hey @neethup 

 

In that case, you can show an error message when the input is not entered properly or you can clear the Text Input as well.
 
To clear the Text Input, please update the configuration as:
OnChange: If(!IsMatch(TextInput1.Text,"^(\([0-9]{3}\) |[0-9]{3}-)[0-9]{3}-[0-9]{4}$"),Set(ResetInput,true);Set(ResetInput,false))
Reset: ResetInput
 
To show error message, please update the configuration as:
Visible: If(!IsMatch(TextInput1.Text,"^(\([0-9]{3}\) |[0-9]{3}-)[0-9]{3}-[0-9]{4}$"),true,false)
 
You can replace highlighted regex with the one that suits you scenario.
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

8 REPLIES 8
Highlighted
Dual Super User III
Dual Super User III

Re: Validate Phone number

Hey @neethup 

 

Can you share more details about the kind of validation you want to perform?
 
There is no such direct way to auto add dash/brackets in an input text. You can set the Format property to Number so that it only accepts numbers and set the Maximum length to 10.
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
Highlighted
Helper IV
Helper IV

Re: Validate Phone number

@yashag2255  Hi.. i just want to validate whether the input phone number is in the right format or not.. if its not want to show a validation error

Highlighted
Dual Super User III
Dual Super User III

Re: Validate Phone number

Hey @neethup 

 

Do you want the user to enter numbers only or the brackets and hyphens too?

Highlighted
Helper IV
Helper IV

Re: Validate Phone number

@yashag2255  user should eneter bracket and slash too

Highlighted
Dual Super User III
Dual Super User III

Re: Validate Phone number

Hey @neethup 

 

In that case, you can show an error message when the input is not entered properly or you can clear the Text Input as well.
 
To clear the Text Input, please update the configuration as:
OnChange: If(!IsMatch(TextInput1.Text,"^(\([0-9]{3}\) |[0-9]{3}-)[0-9]{3}-[0-9]{4}$"),Set(ResetInput,true);Set(ResetInput,false))
Reset: ResetInput
 
To show error message, please update the configuration as:
Visible: If(!IsMatch(TextInput1.Text,"^(\([0-9]{3}\) |[0-9]{3}-)[0-9]{3}-[0-9]{4}$"),true,false)
 
You can replace highlighted regex with the one that suits you scenario.
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

Highlighted
Helper IV
Helper IV

Re: Validate Phone number

@yashag2255 Thanks

Highlighted
Helper IV
Helper IV

Re: Validate Phone number

 @yashag2255  I have added a label to show error message but it is not going when the condition is true..

onchange-If(!IsMatch(TextInput1.Text,"^(\([0-9]{3}\) |[0-9]{3}-)[0-9]{3}-[0-9]{4}$"),Set(ResetInput,false),Set(ResetInput,true))

Label visible(to show msg)-If(ResetInput,false,true)

Label Text= Not a valid phone no

 I have included this

Highlighted
Dual Super User III
Dual Super User III

Re: Validate Phone number

Hi @neethup 

 

ResetInput is a variable defined to reset the control. This works totally different and cannot be used for setting up the visibilty of the error message. Please update the expressions as:
 

onchange-If(!IsMatch(TextInput1.Text,"^(\([0-9]{3}\) |[0-9]{3}-)[0-9]{3}-[0-9]{4}$"),Set(ResetInput,true);Set(ResetInput,false))

 

Label visible(to show msg)-If(IsBlank(TextInput1.Text) || IsMatch(TextInput1.Text,"^(\([0-9]{3}\) |[0-9]{3}-)[0-9]{3}-[0-9]{4}$"),false,true)

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (7,360)