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

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Users online (6,206)