<script>
var
regBox = {
regEmail : /^([a-z0-9_/.-]+)@([/da-z/.-]+)/.([a-z/.]{2,6})$/,
//....邮箱
regName : /^[a-z0-9_-]{3,16}$/,
//....用户名
regMobile : /^0?1[3|4|5|8][0-9]/d{8}$/,
//....手机
regTel : /^0[/d]{2,3}-[/d]{7,8}$/ //....电话
}
var
mymail =
[email protected]'
;
var
myusername =
'akgdk好123'
;
var
mobile =
'18758089867'
;
var
tel =
'0575-7678899'
;
var
mailflag = regBox.regEmail.test(mymail);
var
nameflag = regBox.regName.test(myusername);
var
mflag = regBox.regMobile.test(mobile);
var
tflag = regBox.regTel.test(tel);
if(!mailflag){
alert(
"输入的邮箱有误!"
);
}
else if(!nameflag){
alert(
"输入的用户名含有非法字符!"
);
}
else if(!(mflag&&tflag)) {
alert(
"手机或者电话有误!"
);
}
else
{
alert(
"输入的信息正确!"
);
};
</script>
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/17386.html