登录代码
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Title</title> 6 <script src="js/jquery-easyui-1.5/jquery.min.js"></script> 7 <script type="text/javascript" src="js/jquery-easyui-1.5/jquery.min.js"></script> 8 <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"> 9 <script type="text/javascript" src="js/bootstrap.min.js"></script> 10 <link rel="stylesheet" href="css/login.css"> 11 <script src="js/fun_js/login.js"></script> 12 13 </head> 14 <body> 15 <div class="contains"> 16 <div id="div1"> 17 <div class="tab"><i></i><span>登录</span></div> 18 <form class="form-horizontal" role="form"> 19 <div class="form-group"> 20 <!-- <label for="username" class="col-sm-2 control-label">昵称</label>--> 21 <div class="col-sm-10"> 22 <input type="text" class="form-control" name="usert.username" id="username" 23 placeholder="请输入用户名" autocomplete="off" ><label id="message"></label> 24 </div> 25 </div> 26 <div class="form-group"> 27 <!-- <label for="password" class="col-sm-2 control-label">密 码</label>--> 28 <div class="col-sm-10"> 29 <input type="text" class="form-control" name="usert.password" id="password" 30 placeholder="6-12位密码" autocomplete="off" > 31 </div> 32 </div> 33 <div class="form-group"> 34 <div class="col-sm-offset-2 col-sm-10"> 35 <button type="submit" class="btn btn-default" id="tijiao"onclick="checkuser()"><a href="home.html">登录</a></button> 36 </div> 37 </div> 38 </form> 39 <div class="login_btn"> 40 <a href="regist.html">没有账号,点击注册</a> 41 </div> 42 </div> 43 </div> 44 <script> 45 46 function login() { 47 document.location.href="home.html"; 48 } 49 </script> 50 </body> 51 </html>
js脚本
/** * Created by wei on 2017/9/21. */ function checkuser() { var user_name = $("#username").val(); var password = $("#password").val(); // alert(user_name); $.ajax({ type: "post", async: false, url: "http://localhost:8080/GD/LoginAction_check.action", dataType: "json", data:{ "username" : user_name, "password":password, }, success: function (data) { if(data == 0){ alert("用户名或密码错误"); }else if(data == 1){ console.log("用户名正确"); } } }); }
css样式
#div1{width:500px;height: 300px;background-color: #00b38a;margin: 100px auto;padding-left: 60px;padding-top: 20px;} .tab{margin-bottom: 20px;} .tab span{font-size: 20px;}