加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

正则表达式验证 手机号 、邮箱。。。。

发布时间:2020-12-14 01:44:02 所属栏目:百科 来源:网络整理
导读://手机号验证 valid = /^0?(12[0-9]|13[0-9]|14[57]|15[012356789]|16[0-9]|17[0-9]|18[0-9]|19[0-9])[0-9]{8}$/; if (!valid.test($("#tel").val())) { document.getElementById('telyz').innerText = "格式不正确..."; } else { document.getElementById('
//手机号验证
valid = /^0?(12[0-9]|13[0-9]|14[57]|15[012356789]|16[0-9]|17[0-9]|18[0-9]|19[0-9])[0-9]{8}$/;
if (!valid.test($("#tel").val())) {
document.getElementById('telyz').innerText = "格式不正确...";
} else {
document.getElementById('telyz').innerText = "";

}

//邮政编码验证
var re = /^[1-9][0-9]{5}$/;
if (!re.test($("#postcode").val())) {
document.getElementById('bmyz').innerText = "格式不正确...";
} else {
document.getElementById('bmyz').innerText = "";
}

//非法用户字符检查

var patten=/^[a-zA-Z]{1,}[a-zA-Z0-9_]*$/;
if(!patten.test(vid)){
//alert("用户名不合法!");
layer.alert("用户名不合法",18);
return false;
}

//邮箱验证

var patrn = /^w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*$/; if(!patrn.test(email)){ alert("Email格式不正确..."); return; }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读