js电话验证

function checkPhone() {
phone = $('#phone').val();
var tel_str = /^(1[358]\d{9}|170\d{8}|0\d{2,3}(-)?\d{7,8})$/
if (phone === '') {
errorPhone.html('电话不能为空!');
return false;
}
else if (!tel_str.test(phone)) {
errorPhone.html('请输入正确的电话号码!');
return false;
}
else {
errorPhone.html('');
return true;
}
}

猜你喜欢

转载自blog.csdn.net/liuyinglilmm/article/details/44965409
今日推荐