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

Phone number Validation - Count numerical characters

I have a requirement to validate a phone number which has exactly 10 numerical characters in the validation regardless of non numerical like hyphen, space, brackets etc

 

Basically it should validate all three examples below.

 

234-234-3455

2342343455

(234) 234-3455 

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
KrishnaV
Community Champion
Community Champion

Hi @Lana ,

 

Please try this:

IsMatch(txtPhoneVal.Text,"^(\(?[0-9]{3}\)?|[0-9]{3})( |-)?([0-9]{3}( |-)?[0-9]{4}|[a-zA-Z0-9]{7})$")

 the above formula works for all the given 3 scenarios:

234-234-3455

2342343455

(234) 234-3455

 

I have tested it and working as expected.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
Krishna
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.

 


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
KrishnaV
Business Applications MVP, Microsoft Certified Trainer
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

View solution in original post

5 REPLIES 5
KrishnaV
Community Champion
Community Champion

Hi @Lana ,

 

Please try this:

IsMatch(txtPhoneVal.Text,"^(\(?[0-9]{3}\)?|[0-9]{3})( |-)?([0-9]{3}( |-)?[0-9]{4}|[a-zA-Z0-9]{7})$")

 the above formula works for all the given 3 scenarios:

234-234-3455

2342343455

(234) 234-3455

 

I have tested it and working as expected.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
Krishna
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.

 


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
KrishnaV
Business Applications MVP, Microsoft Certified Trainer
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.
EricRegnier
Super User
Super User

HI @Lana, if you're using model-driven apps, you can follow these steps with the Input Mask control:

  1. Open your solution that contains that entity and open the main form. Click the "switch to classic" button on the top
  2. Select the phone number field and click "Change Properties"
  3. Navigate to the Controls tab and click on "Add Control"
  4. Select "Input Mask" and click add
  5. Pick you field for the Field property
  6. Enter the mask (e.g. 00000000000) for the Mask property. You can also put dashes
  7. Ensure the Input Mask control is selected for Web, Phone and Tablet.
  8. Save all and publish all customization

2020-06-20_10-09-00.png

Hope this helps!

v-xida-msft
Community Support
Community Support

Hi @Lana ,

Do you want to achieve your needs inside a canvas app?

Do you want to validate if a entered 10 numerical characters is a valid phone number?

 

I have made a test on my side, please try the following workaround:

11.JPG

Set the Text property of the Label to following:

IsMatch(TextInput2.Text, "(\()?\d{3}(\))?(\s|\-)?\d{3}(\-)?\d{4}")

Note: The TextInput2.Text represents the 10 numerical characters text you want to detect. If the Label show true, represents the entered 10 numerical characters is valid, otherwise, it's invalid.

 

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.
Anonymous
Not applicable

Thank you for all your responses. I ended up using KrishnaV solution and it worked.

KrishnaV
Community Champion
Community Champion

Hi @Anonymous ,

 

I am very glad that my solution worked for you. Would you mind mark that as a solution so that the new members of the community will make use of it. Thank you very much for your support in the community.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
Krishna
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
KrishnaV
Business Applications MVP, Microsoft Certified Trainer
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

Helpful resources

Announcements
Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

<
Users online (3,003)