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

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
v-xida-msft
Community Support
Community Support

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

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

 

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.

v-xida-msft
Community Support
Community Support

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

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?

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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

PA Community Call

Power Apps Community Call

Next call is happening on April 21st at 8a PST.

MBAS Carousel

Sign up for our May 4th event!

May the fourth be with you, join us online!

secondImage

Experience what’s next for Power Apps

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

Top Solution Authors
Top Kudoed Authors
Users online (15,170)