<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{
document.getElementById("submit").disabled=false;
}
}