1. 程式人生 > >用javascript實現簡單的用戶登錄驗證

用javascript實現簡單的用戶登錄驗證

-c turn get https 沒有 驗證 utf-8 .com head

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>Document</title>
 6 </head>
 7 <body>
 8     <script type="text/javascript">
 9         function check() {
10             if(document.getElementById(
"username").value=="") { 11 alert("沒有輸入用戶名!"); 12 return false; 13 } else if(document.getElementById("password").value=="") { 14 alert("沒有輸入密碼!"); 15 return false; 16 } else { 17 alert("提交成功!
") 18 return true; 19 } 20 } 21 </script> 22 <form name="form1"> 23 <input type="text" id="username"> 24 <input type="password" id="password" > 25 <input type="submit" onclick="check()"> 26 </form> 27
</body> 28 </html>

更多參考:牛客網 https://www.nowcoder.com/questionTerminal/f904c482f21346a6a19efd5a82655518

用javascript實現簡單的用戶登錄驗證