使用Js完成注册页面表单校验
2017-12-28 13:51
441 查看
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>注册页面</title> <script> function checkForm(){ //1.获取用户输入的数据 var uValue = document.getElementById("user").value; if(uValue==""){ //2.给出错误提示信息 alert("用户名不能为空!"); return false; } /*校验密码*/ var pValue = document.getElementById("password").value; if(pValue==""){ alert("密码不能为空!"); return false; } /**校验确认密码*/ var rpValue = document.getElementById("repassword").value; if(rpValue!=pValue){ alert("两次密码输入不一致!"); return false; } /*校验邮箱*/ var eValue = document.getElementById("eamil").value; if(!/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/.test(eValue)){ alert("邮箱格式不正确!"); return false; } } </script> </head> <body> <table border="1px" align="center" width="1300px" cellpadding="0px" cellspacing="0px"> <form action="#" method="get" name="regForm" onsubmit="return checkForm()"> <table border="1px" width="750px" height="400px" align="center" cellpadding="0px" cellspacing="0px" bgcolor="white"> <tr height="40px"> <td colspan="2"> <font size="4">会员注册</font> </td> </tr> <tr> <td> 用户名 </td> <td> <input type="text" name="user" size="34px" id="user"/> </td> </tr> <tr> <td> 密码 </td> <td> <input type="password" name="password" size="34px" id="password"/> </td> </tr> <tr> <td> 确认密码 </td> <td> <input type="password" name="repassword" size="34px" id="repassword"></input> </td> </tr> <tr> <td> Emaile </td> <td> <input type="text" name="email" size="34px" id="eamil"/> </td> </tr> <tr> <td colspan="2"> <input type="submit" value="注册" /> </td> </tr> </table> </form> </td> </tr> </table> </body> </html>
相关文章推荐
- JavaScript学习——使用JS完成注册页面表单校验
- 编程心得+使用JS完成注册页面表单校验
- 使用JS完成注册页面表单简单校验
- JavaEE day03 使用JS完成简单的数据校验、完成图片轮播效果、完成页面定时弹出广告、完成表单校验
- 教你一天玩转JavaScript(五)——使用JavaScript完成注册页面表单提示及校验
- 正则表达式及js校验表单代码(注册页面)
- php用户注册页面使用js进行表单验证具体实例
- JavaScript 完成注册页面表单校验的实例
- JS应用实例1:注册页面表单校验
- 请写一个简单的幻灯效果页面。如果不使用JS来完成,可以加分。
- php用户注册页面利用js进行表单验证
- 请写一个简单的幻灯效果页面。如果不使用JS来完成,可以加分。
- 请写一个简单的幻灯效果页面。如果不使用JS来完成,可以加分。
- php用户注册页面利用js进行表单验证
- 请写一个简单的幻灯效果页面。如果不使用JS来完成,可以加分。
- 请写一个简单的幻灯效果页面。如果不使用JS来完成,可以加分。
- 请写一个简单的幻灯效果页面。如果不使用JS来完成,可以加分。
- 请写一个简单的幻灯效果页面。如果不使用JS来完成,可以加分。
- 使用jQuery制作高级炫酷吊炸天表单,页面加载完成文本框获得焦点,文本框设置默认文本,文本字数动态显示.....
- [javascript library]使用js实现页面刷新后依然保留表单填写的数据