Js authentication phone number and mobile support +86 regular expressions
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head> <title> Regular expression validation </title> <script type="text/javascript" src="../Scripts/jquery-1.4.1.min.js"></script> <script type="text/javascript"> var Validate = { isTel: function (s) { var patrn = /^((+?86)|((+86)))?d{3,4}-d{7,8}(-d{3,4})?$/ if (!patrn.exec(s)) return false return true }, isMobile: function (value) { var validateReg = /^((+?86)|((+86)))?1d{10}$/; return validateReg.test(value); }, cellPhone: function () { var cellPhoneNumber = $("#txtCellPhone").val(); if (!Validate.isMobile(cellPhoneNumber)) { alert(" Incorrect phone number format "); return false; } else { alert(" Your phone number format is correct "); } }, telePhone: function () { var telePhoneNumber = $("#txttelePhone").val(); if (!Validate.isTel(telePhoneNumber)) { alert(" The phone number is not formatted correctly "); return false; } else { alert(" Your phone number is in the correct format "); } } } </script></head><body><div> <label> Please enter your mobile phone number (support +86 ) : </label><input type="text" id="txtCellPhone" /><input type="button" value=" validation " onclick="Validate.cellPhone();"/><br /> <label> Please enter your phone number (support +86 ) : </label><input type="text" id="txttelePhone" /><input type="button" value=" validation " onclick="Validate.telePhone();"/><br /></div></body></html>