Html:

<!DOCTYPE html>
<html>
<body>
<label>UserName</label><br>
<input id="username"><br>
<label>Password</label><br>
<input id="password"><br>
<button onclick="myFunction()">Validate</button>

<script>
function myFunction() {
   if(document.getElementById("username").value=="user1")
   {
    if(document.getElementById("password").value=="123")
    {
    alert("yes");
    } 
    else
    {
      alert("no");
    }
   }
   else
  {
    alert("no");
  }


}
</script>

</body>
</html>

新的学习-Html-简单的验证用户名密码是否输入正确

以上验证是当输入了正确的用户名和密码会提示yes,反之则不行。

相关文章:

  • 2022-12-23
  • 2021-10-08
  • 2022-12-23
  • 2022-12-23
  • 2021-09-07
  • 2021-09-01
  • 2021-12-12
  • 2022-12-23
猜你喜欢
  • 2021-12-22
  • 2021-11-06
  • 2021-09-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案