牛骨文教育服务平台(让学习变的简单)
博文笔记

注册(Ajax验证)

创建时间:2018-10-19 投稿人: 浏览次数:627

<html>

  <head>

    <script>

          function checkage(){

         var age=document.getElementById("age").value;

         if(age<16||age>24){

         alert("输入年龄范围应该为16岁至24岁");

         document.getElementById("age").focus();

         return false;

         }

         }

   function checkpassword(){

        var password = document.getElementById("password").value;

        var repassword = document.getElementById("repassword").value;

        if(password == ""){

          alert("请输入密码");

          document.getElementById("password").focus();

          return ;

        }

        

        if(password != repassword){

         alert("输入的密码不一致,请重新输入");

          document.getElementById("password").focus();

}}

 

    </script>

 

  </head>

  

  <body background="h.jpg">

  <h1 align="center">

  <font color="red">注册</font></h1>

<form name="form1" action="">

<table align="center"><tr>

<td>用户名</td>

<td><input type="text" name="username" id="username" onblur="checkuser()"/></td>

 

</tr>

 

 

<tr>

<td>密码</td>

<td><input type="password" name="password" id="password"/></td>

</tr>

<tr>

<td>确认密码</td>

<td><input type="password" name="repassword" id="repassword" onblur="checkpassword()"/></td>

</tr>

<tr>

<td>年龄</td>

<td><input type="text" name="age" id="age" onblur="checkage()"/></td>

</tr>

<tr>

<td><input type="submit" value="注册"/></td>

<td><input type="reset" value="重置"/></td>

</tr>

 

</table></form>

  </body>

</html>

声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。