Javascript验证练习。请求师兄修改bug 。出错时候为什么不能显示 “确定”按钮??

来源:互联网 发布:阿拉伯语自学软件 编辑:程序博客网 时间:2024/04/29 21:59

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>无标题页</title>
    <style type="text/css">
            div {width:200;height:40;color:red}
          </style>
         
          <script type="text/javascript">
                               

    function login()
    {       
             wrong.style.display = "block";
        
             var sst=new person(txt_name.value ,txt_paswd.value );
             if(""==txt_name.value||""==txt_paswd.value )
             {
             wrong.innerHTML = "请输入完整的信息";

             }
             else
             {
             if(txt_name.value !="a" && txt_paswd.value !="a")
             {
            
             wrong.innerHTML="请输入正确信息";

             }
             else
             {
                  sst.show();
            wrong.style.display = "none";
             }
           
             }
   
    }
//    function ckpas()
//    {
//   
//      if(txt_paswd.value =='')
//      alert("mima bu neng wei kong ");
//      document.getElementById ("txt_paswd")="";
//        document.getElementById ("txt_paswd").focus();
//     
//   
//    }
    function person(name,paswd)
   
    { 
     
       this.name=name
       this.paswd=paswd;
      this.show=function(){
     
     
     
      alert("恭喜您输入正确"+"/n姓名:"+this.name);
        
     
      }
    }
   
    function clearn()
    {
      txt_name.value="";
     txt_paswd.value="";
    
    }
     
   
    </script>
</head>
<body>

    <div id ="wrong" style="text-align: center">
        <table style="width: 300pt; height: 74pt">
            <tr>
                <td style="width: 100px; height: 26px">
                    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; 用户名</td>
                <td style="width: 100px; height: 26px">
                    <input id="txt_name" name="name" type="text"  /></td>
            </tr>
            <tr>
                <td style="width: 100px; height: 28px">
                    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;密码</td>
                <td style="width: 100px; height: 28px">
                    <input id="txt_paswd" name="paswd" style="width: 149px" type="password" /></td>
            </tr>
            <tr>
                <td colspan="2">
                    <input id="Reset1" style="left: 94px; position: relative; top: 0px" type="reset"
                        value="重置"   onclick = "clearn();" />
                    <input id="Button1" style="left: -11px; position: relative; top: 0px" type="button"
                        value="登陆"     onclick = "login();"  />
                </td>
            </tr>
            <tr>
                <td colspan="2" style="height: 22px">
                </td>
            </tr>
        </table>
    </div>

</body>
</html>

原创粉丝点击