//userinfo是from表单名(name),email是文本框名(name)
if(document.userinfo.email.value.length!=0) { if (document.userinfo.email.value.charAt(0)=="." || document.userinfo.email.value.charAt(0)=="@"|| document.userinfo.email.value.indexOf('@', 0) == -1 || document.userinfo.email.value.indexOf('.', 0) == -1 || document.userinfo.email.value.lastIndexOf("@")==document.userinfo.email.value.length-1 || document.userinfo.email.value.lastIndexOf(".")==document.userinfo.email.value.length-1) { alert("Email地址格式不正确!"); document.userinfo.email.focus(); return false; } }else { alert("Email不能为空!"); document.userinfo.email.focus(); return false; }