dreamflycc
<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>

 

分类:

技术点:

相关文章:

  • 2021-10-29
  • 2021-12-08
  • 2022-12-23
  • 2021-11-12
  • 2021-12-04
  • 2022-12-23
猜你喜欢
  • 2022-02-07
  • 2021-12-11
  • 2022-12-23
  • 2022-01-07
相关资源
相似解决方案