赞
踩
novalidate="true"取消表单默认验证,自己来处理结果,email.checkValidity()验证方法
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8" />
- <title></title>
- </head>
- <body><a href="http://s.jf3q.com">click here</a>
- <form οnsubmit="testform()" novalidate="true">
- <label for="email"> 邮箱:</label>
- <input type="email" id="email" name="email"/>
- <input type="submit" value="提交">
- </form>
- </body>
-
-
- <script>
- function testform(){
- var email=document.getElementById('email');
- if(email.value==''){
- alert('请输入email!');
- return false;
- }else if(!email.checkValidity()){
- alert('email的格式不正确!');
- return false;
- }
- }
- </script>
- </html>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。