Regex for a phone number where a phone number exclusively contains numbers in the range of 5 to 15 digits

RashedRahat :

My regex:/[0-9]{5,15}/ that satisfies a number e.g. 8801778620485 which is fine. But it also satisfies a number i.e 8801778620485|123456|987123456 (Three parts are a single phone number). I don't want this kind of phone number to be accepted. I want exclusively numbers without any special characters like (|, ?, *, -) these no special characters are allowed, only numbers are allowed.

Anuj Pancholi :

number.match(/^\d{5,15}$/);

This should work \d for [0-9], and start and end of the expression specified so that a a string like 123456|12345678 doesn't result in a partial match.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=21831&siteId=1