1. 只能输入数字和字母
<input onkeyup="value=value.replace(/[^w./]/ig,'')" />
2. 邮箱验证
<input type="submit" class="stdbtn" onclick="return checkEmail()"/> function checkEmail(e){ console.log(e) var $email=$("#email").val(); if(!$email.match(/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$/)){ alert("格式不正确!请重新输入"); $("#email").focus(); return false; } }
3.手机号验证
//手机号正则表达式如下,适用于联通 电信 移动 手机号
var reg =/^[1][3,4,5,7,8][0-9]{9}$/;
if(!reg.test(phone)){
this.$message.error("您输入的手机号不正确,请重新输入!");
return false;
}