cancel
Showing results for
Did you mean:
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
Community Champion

Hi @Lana ,

``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
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.
5 REPLIES 5
Community Champion

Hi @Lana ,

``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
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.
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"
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

Hope this helps!

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:

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.

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
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.

Announcements

#### Welcome Super Users

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