用HTML和JS做简单的注册验证
来源:互联网 发布:个性化排序算法 编辑:程序博客网 时间:2024/04/20 17:05
题目如下:
初学web,主要熟悉一下javascript和简单正则表达式的用法。
<!--To change this template, choose Tools | Templatesand open the template in the editor.--><!DOCTYPE html><html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script type="text/javascript"> function validate(){ var flag=1; if(!/^\d+$/.test(document.emp.empno.value)) { document.getElementById("errorno").innerHTML="<font color='red'>雇员编号必须是数字</font>"; document.emp.empno.focus(); document.emp.empno.select(); flag=0; } if(!/^\S+$/.test(document.emp.empname.value)) { document.getElementById("errorname").innerHTML="<font color='red'>雇员姓名不能为空</font>"; document.emp.empname.focus(); document.emp.empname.select(); flag=0; } if(!/^\S+$/.test(document.emp.empjob.value)) { document.getElementById("errorjob").innerHTML="<font color='red'>雇员工作不能为空</font>"; document.emp.empjob.focus(); document.emp.empjob.select(); flag=0; } if(!/^\d{4}-\d{2}-\d{2}$/.test(document.emp.emphiredate.value)) { document.getElementById("errorhiredate").innerHTML="<font color='red'>雇佣日期格式必须为xxxx-xx-xx,如2013-11-11</font>"; document.emp.emphiredate.focus(); document.emp.emphiredate.select(); flag=0; } if(!/^\d*[.]?\d+$/.test(document.emp.empsalary.value)) { document.getElementById("errorsalary").innerHTML="<font color='red'>雇员工资必须是数字(小数)</font>"; document.emp.empsalary.focus(); document.emp.empsalary.select(); flag=0; } if(!/^\d*[.]?\d+$/.test(document.emp.empbonus.value)) { document.getElementById("errorbonus").innerHTML="<font color='red'>雇员奖金必须是数字(小数)</font>"; document.emp.empbonus.focus(); document.emp.empbonus.select(); flag=0; } if(flag==0)return false; else return true; } </script> </head> <body> <form name="emp" method="post" action="index.jsp" onsubmit="return validate()"> 雇员编号:<input type="text" name="empno" /> <span id="errorno"></span><br /> 雇员姓名:<input type="text" name="empname" /> <span id="errorname"></span><br /> 雇员工作:<input type="text" name="empjob" /> <span id="errorjob"></span><br /> 雇佣日期:<input type="text" name="emphiredate" /> <span id="errorhiredate"></span><br /> 雇员工资:<input type="text" name="empsalary" /> <span id="errorsalary"></span><br /> 雇员奖金:<input type="text" name="empbonus" /> <span id="errorbonus"></span><br /> <input type="submit" value="提交"> <input type="reset" value="重置"> </form> </body></html>
- 用HTML和JS做简单的注册验证
- js对注册页面的简单验证
- 使用js实现简单的注册验证
- JS做简单的验证码
- js和html的注册页面
- js和html的注册页面
- 用html做一个邮箱的注册
- 一个简单的注册登录页面(包括阿里大于的手机验证)html+JS+AJAX+PHP
- 注册页面的js验证
- 注册页面的js验证 .
- boodstrap 简单的 注册验证
- Zend Framework 教程:简单的注册和登录验证
- web实现验证码和简单的登录注册
- webpy实现简单的登录注册和对应验证
- 用ajax做简单的数据验证
- JS和HTML分离:注册事件的方法进行封装
- 简单的Html和JavaScript:用户注册页面
- js和html的简单问题
- hdu 1429胜利大逃亡(续)
- 基于单幅图像的2D转3D算法研究
- ipc 通讯之ftok
- 关于javah编译出错的小问题
- 深入理解windows 消息机制
- 用HTML和JS做简单的注册验证
- java socket通信
- C# TreeView绑定 能展示xml属性
- C语言运算符优先级和口诀
- loadrunner走socket协议写发送数据脚本
- 选择问题的算法
- listfragment onlistitemclick 没有响应 没有调用
- SSH不能连接并提示REMOTE HOST IDENTIFICATION HAS CHANGED解决
- dos 批处理