x
 
<!DOCTYPE html>
<html>
<body>
<form>
用户名:<input type="text" id="usrname"><br>
密码:<input type="password" id="myPsw">
</form><br>
<button onclick="disablePsw()">禁用密码字段</button>
<button onclick="undisablePsw()">取消禁用密码字段</button>
<script>
function disablePsw() {
  document.getElementById("myPsw").disabled = true;
}
function undisablePsw() {
  document.getElementById("myPsw").disabled = false;
}
</script>
</body>
</html>