Introduction:
In this article we will discuss about how to testing and validating a phone number.
Main:
Normally phone numbers are varry from one place to another,so first we need to declare phone number format.
For ex (CCC) NNN-NNNN-NN
CCC -> Country Code,
NNN-NNNN-NN -> Phone Number,
Code:
var telephoneNo = “(01) 7555 5555″;
var pattern = /^(\(\d+\) ?)?(\d+[\- ])*\d+$/;//Regular expression for this phone no format
var a = pattern.test(telephoneNo);
^(\(\d+\) ?)? At the start of the string, you may optionally have an open round bracket, followed by one or more numbers, followed by a closed round bracket, optionally followed by a space.
(\d+[\- ])* You may then have zero or more groups of one or more digits. Each of these groups must be followed by a space or a hyphen.
\d+$ Finally, the string must end with one or more digits.
Conclusion:
Hope,this helps,
Happy Coding.
I wanted to thank you for this excellent read!! I definitely enjoyed every little bit of it. I have you bookmarked your site to check out the new stuff you post.
Thanks for writing, I very much liked your newest post. I think you should post more frequently, you evidently have natural ability for blogging!
thanks !! very helpful post!
This post is beyond awesome. I am always wondering what to do and what not to do so I will follow some of these tips.
Cool post I will continue to look out for anymore of your future posts.
This should help me to fix the issues which i have got, many thanks.
I’m delighted! After reading your post I can tell you are passionate about your writing. Keep up the great work and I’ll return for more! Thank you.
Fantastic post! This could aid lots of people find out about this matter. Do you want to incorporate video clips together with these? It could undoubtedly
I’m delighted! After reading your post I can tell you are passionate about your writing. Keep up the great work and I’ll return for more! Thank you.
After reading your post I can tell you are well-informed about your writing. Thank you.
Marvelous, thanks for posting!
I found this page via google, and it explains what I was trying to figure out. Thanks!
I read a few topics. I respect your work and added blog to favorites.
It is remarkable, it is an amusing phrase
This was a great site. I bare to acquisition something for myHmoework and This website helped me out so much! Thanx alot!!!!
Love your post. This is great information, and I’m really glad I found it. Keep up the superb work.
I read a few topics. I respect your work and added blog to favorites.
Great information, I will be linking back to you and going to look around at your other posts.