html button控件 非活性

来源:互联网 发布:网络微电影排行榜 编辑:程序博客网 时间:2024/04/29 19:54

<html>
 <head>
  <title>Login</title>
  <script type="text/javascript" src="show.js">
  </script>
 </head>
 <body>
  <table>
   <tr>
    <td>
     用户名:
    </td>
    <td>
     <input type="text" name="userId" id="userId" style="width: 150px" maxlength="9"/>
    </td>
   </tr>
   <tr>
    <td>
     密  码:
    </td>
    <td>
     <input type="password" name="password" style="width: 150px;" size="20" id="password" onkeyup="javascript:show()"/>
    </td>
   </tr>
   <tr>
    <td colspan="2" align="center">
     <input type="button" name="submit" style="width: 50px; height: 25" value="登陆" id="submit" disabled />
    </td>
   </tr>
  </table>
 </body>
</html>

show.js
   function show(){
    var userId = document.getElementById("userId").value;
    var password = document.getElementById("password").value;
    if(userId =="" || password ==""|| userId ==null || password ==null){
     document.getElementById("submit").disabled=true;
    }else{    www.2cto.com
     document.getElementById("submit").disabled=false;
    }
   }

原创粉丝点击