JS練習_對已知賬號密碼驗證進行登錄


預覽效果:

源碼演示:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Login</title>
  <script>
    function valid(){
      var pwd1 = document.getElementById("pwd").value;
      var pwd2 = "123456";
      var acc1 = document.getElementById("acc").value;
      var acc2 = "Mark";
    //  已被設置的賬號與密碼的驗證
      if (pwd1 == pwd2 && acc1 == acc2)
      {
        document.getElementById("tishi").innerHTML="<font color = 'green'>登錄成功</font>"
        document.getElementById("button").disabled = false;
      }
      else {
        document.getElementById("tishi").innerHTML="<font color = 'red'>登錄失敗</font>"
        document.getElementById("button").disabled = true;
      }
    }
  </script>
</head>
<body>
<div class="form">
  <label>賬號</label>
  <div>
    <input type="text" class="form_1" name="acc" id="acc" placeholder="賬號">
  </div>
</div>
<div class="form">
  <label>請輸入密碼</label>
  <div>
    <input type="password" class="form_1" name="pwd" id="pwd" placeholder="密碼">
  </div>
</div>
<input type="button" value="登錄" onclick="valid()">
<p id="tishi"></p>
</body>
</html>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM