Reputation: 3367
I need a Javascript RegEx through which I can validate phone number. RegEx should handle following criteria
Thanks for the help!
Hussain.
Upvotes: 1
Views: 1312
Reputation: 163238
Try this:
function valid_phone_number(ph) {
var regex = /^(?!([^-]*-){5})(\+\d+)?\s*(\(\d+\))?[- \d]+$/gi;
return regex.test(ph);
}
I'm new to regular expressions, so please be nice. :-)
Upvotes: 7