zoukankan      html  css  js  c++  java
  • 表单验证

    进行布局;
     <form action="网页/新网页.html" method="post">
            	用户名:<input type="text" name="y" id="y" /><br />
                密码:<input type="password" name="p" id="p" /><br />
                确认密码:<input type="password" name="qp" id="qp"/><br />
                年龄:<input type="text" name="n" id="n" /><br />
                手机号:<input type="text" name="s" id="s" /><br />
            	<input type="submit" value="提交" onclick="return Ti()" />
            </form>
    

      

    function Ti()
    		{   //不能为空。
    		    var y = document.getElementById("y").value;
    //年龄的范围 var n = document.getElementById("n").value;
    //手机号正则判断 var s = document.getElementById("s").value;
    var z =/^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])d{8}$/; if(y=="" || p=="" || qp=="" || n=="" || s=="") { alert("不能有空的"); return false; } else { //密码是否相同 var p = document.getElementById("p").value; var qp = document.getElementById("qp").value; if(p!=qp || p=="") { alert("输入的密码正确") return false; } else { if(n>50 && n<16) { alert("年龄不符"); return false; } else { if(s.match(z)==null) { alert("手机号不正确"); return false; } else { return true; } } } } }

      

  • 相关阅读:
    find命令之xargs
    find命令之exec
    find 命令概览
    mv命令
    locate 命令
    whereis 命令
    linux which 查看可执行文件的位置
    Linux应用总结:自动删除n天前日志
    Visual Studio
    Visual Studio- “无法启动此程序,因为计算机中丢失 xxx.dll尝试重新安装该程序以解决此问题"
  • 原文地址:https://www.cnblogs.com/cy960202/p/8845823.html
Copyright © 2011-2022 走看看