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

Validate Phone number

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

1 ACCEPTED SOLUTION

Accepted Solutions
Dual Super User
Dual Super User

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
Dual Super User
Dual Super User

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!
neethup
Level: Powered On

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
Dual Super User

Re: Validate Phone number

Hey @neethup 

 

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

neethup
Level: Powered On

Re: Validate Phone number

@yashag2255  user should eneter bracket and slash too

Dual Super User
Dual Super User

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

neethup
Level: Powered On

Re: Validate Phone number

@yashag2255 Thanks

neethup
Level: Powered On

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

Dual Super User
Dual Super User

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
thirdimage

New Badges

Check it out!

thirdimage

Power Apps 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

Top Solution Authors
Top Kudoed Authors
Users online (4,686)