手机号码输入验证:
function isPhoneNum(str) {
return /^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/.test(str)
}
案例:
if ($('#phone').val()!="")
{
var Phonenumber = $('#phone').val();
if (!isPhoneNum(Phonenumber))
{
layer.msg("手机号码输入不正确!")
$('#phone').focus();
return false;
};
}
<input type="number" class="input-text radius size-MINI" style="width:120px" id="phone" name="phone" >
摘自:https://blog.youkuaiyun.com/jason_renyu/article/details/79241590