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

Validate telephone number

I am trying to use IsMatch function to validate telephone number text input which only allowed user to enter digit. No special characters such as "-" and any space is allowed. 

 

If user enter the wrong format, the BorderColor of the text input will turn into red.

 

Any help would be much appreciated! Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Validate telephone number

Hi @shabila97 ,

Do you want to validate telephone number using IsMatch() function within your app?

How many digits does your telephone number have? 10?

 

Based on the needs that you mentioned, I have made a test on my side, please take a try with the following workaround:1.JPG

Set the BorderColor property of the Text Input box to following:

If(
Not(IsMatch(TextInput1.Text, "\d{10}")) && !IsBlank(TextInput1.Text),
RGBA(255, 0, 0, 1), /* <-- If not match, border color turn into red */
RGBA(0, 18, 107, 1)
)

Note: I assume that the digit of your telephone number is 10.

Please check the following GIF screenshot for more details:Test.gif

The user @er has faced same issue with you, please check the response wihtin the following thread:

https://powerusers.microsoft.com/t5/General-Discussion/Validate-phone-number-email/m-p/42767

 

More details about IsMatch function, please check the following article:

IsMatch function

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Re: Validate telephone number

Hi there,

 

Your function will depend on the format you want!

In the case you want this format : "XXXXXXXXXX", you can put the following code on your BorderColor Statement

If( 
Not(
IsMatch(YourTextBox.Text;Digit & Digit & Digit & Digit & Digit & Digit & Digit & Digit & Digit & Digit)
);
RGBA(255; 0; 0; 1)
)

In the case you want this format : "XX XX XX XX XX", you can put it

If( 
    Not(
        IsMatch(YourTextBox.Text;
Digit & Digit & Match.Space & Digit & Digit & Match.Space & Digit & Digit & Match.Space & Digit & Digit & Match.Space & Digit & Digit) ); RGBA(255; 0; 0; 1) )

Best regards my friend.

 

Louis

 

shabila97
Level: Powered On

Re: Validate telephone number

What about the passport number? As the passport number for every countries have different format.

 

but i just want to validate the passport number to not have any space or special characters such as !@#%^*(" in the text input.

Community Support Team
Community Support Team

Re: Validate telephone number

Hi @shabila97 ,

Do you want to validate telephone number using IsMatch() function within your app?

How many digits does your telephone number have? 10?

 

Based on the needs that you mentioned, I have made a test on my side, please take a try with the following workaround:1.JPG

Set the BorderColor property of the Text Input box to following:

If(
Not(IsMatch(TextInput1.Text, "\d{10}")) && !IsBlank(TextInput1.Text),
RGBA(255, 0, 0, 1), /* <-- If not match, border color turn into red */
RGBA(0, 18, 107, 1)
)

Note: I assume that the digit of your telephone number is 10.

Please check the following GIF screenshot for more details:Test.gif

The user @er has faced same issue with you, please check the response wihtin the following thread:

https://powerusers.microsoft.com/t5/General-Discussion/Validate-phone-number-email/m-p/42767

 

More details about IsMatch function, please check the following article:

IsMatch function

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

shabila97
Level: Powered On

Re: Validate telephone number

Hi @v-xida-msft 

 

Thank you, really appreciate your help!!

 

I have 1 more question, how if i want to validate passport number text input to NOT allowed user to enter any special character such as !@#$%^&* and spaces?

Highlighted
Community Support Team
Community Support Team

Re: Validate telephone number

Hi @shabila97 ,

Do you want to validate the passport number to not have any space or special characters such as !@#%^*(" in the text input?

 

If you want to validate the passport number to not have any space or special characters such as !@#%^*(" in the text input, please modify above formula as below:

If(
Not(IsMatch(TextInput1.Text, "[a-zA-Z0-9]*"))&&!IsBlank(TextInput1.Text),
RGBA( 255, 0, 0, 1 ),
RGBA(0, 18, 107, 1)
)

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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
Users Online
Currently online: 324 members 6,195 guests
Please welcome our newest community members: