1.不能含有中文
var obj = document.form1.txtName.value; if(/.*[u4e00-u9fa5]+.*$/.test(obj)) { alert("不能含有汉字!"); return false; }
2.邮箱
var objName = eval("document.all."+obj); var pattern = /^([.a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/; if (!pattern.test(objName.value)) { alert("请输入正确的邮箱地址。"); objName.focus(); return false; }