js 验证邮箱格式
<script type="text/javascript"> function validate_email(field, alerttxt) { with (field) { apos = value.indexOf("@") dotpos = value.lastIndexOf(".") alert(apos); alert(dotpos); if (apos < 1 || dotpos - apos < 2) { alert(alerttxt); return false } else { return true } } } function validate_form(thisform) { with (thisform) { if (validate_email(email, "不是有效的邮箱地址!") == false) { email.focus(); return false } } } </script>
<form action="XXX.htm" onsubmit="return validate_form(this)"> Email: <input type="text" name="email" size="30"/> <input type="submit" value="Submit"/> </form>
天再高,踮起脚尖就能更接近阳光