javascript - Phone number regex validation -
need validate phone numbers separated comma , can have country code start parameter. need temporary validation in front end side such validating different numbers
- number country code(min length , max length should specified): +919845098450
- number without country code(min length , max length should specified):9845098450
and these numbers separated comma(+919845098450,9845098450 etc) have done single phone number .
^([+])?[0-9()\-#+]*$
and comma separated
^([+])?[,\d{9}]*$
but above regex not showing error when input ends comma (+919845098450,9845098450,).
i need comma separated numbers in jquery/javascript.
if possible need specify min , max length , without country code. appreciated.
you may try this,
/^(?:\+\d{2})?\d{10}(?:,(?:\+\d{2})?\d{10})*$/.test(str);
(?:\+\d{2})?
helps match optional country code.\d{10}
matches 10 digit number.(?:,(?:\+\d{2})?\d{10})*
helps match following 0 or more phone numbers.
Comments
Post a Comment