email表单验证的js代码

来源:互联网 发布:phpsys cms 编辑:程序博客网 时间:2024/04/29 15:14
<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>表单验证</title>    <script>                function validate_form(thisform){                    if(thisform.email.value==null || thisform.email.value==""){                alert("fill the email")                thisform.email.focus();                return false;            }            apos = thisform.email.value.indexOf("@");            dotpos = thisform.email.value.lastIndexOf(".");            if(apos<1 || dotpos-apos < 2){                alert("Not a vaild email");                thisform.email.focus();                return false;            }                    }    </script></head><body>    <form action="val.htm" onsubmit="return validate_form(this)" method="post">        <input type="text" name='email' />        <input type="submit" value="提交" />    </form></body></html>

原创粉丝点击