码迷,mamicode.com
首页 > 编程语言 > 详细

用javascript实现简单的用户登录验证

时间:2017-07-20 18:46:38      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:cti   charset   func   orm   href   nbsp   onclick   meta   com   

 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实现简单的用户登录验证

标签:cti   charset   func   orm   href   nbsp   onclick   meta   com   

原文地址:http://www.cnblogs.com/guorange/p/7212665.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!