<form id="myForm" action="javascript:;" method="post">
<div class="form-group" style=" height:60px; font-size:24px; font-weight:bold; color:#0682C3;padding:20px;text-align:center;">
账号登录
</div>
<div class="form-group">
<input type="text" class="form-control" id="LoginName" placeholder="账号">
</div>
<div class="form-group">
<input type="password" class="form-control" id="LoginPassword" placeholder="密码">
</div>
<div class="form-check">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" id="savepassword" onclick="SavePassword()"> 记住密码
</label>
</div>
<div class="form-group" style="margin-top:30px;">
<button type="submit" class="btn btn-primary btn-block" style="background-color:#0682C3;border-color:#0682C3;" onclick="Submit()">登录</button>
</div>
</form>
form 修改属性action action="javascript:;" 不交互,在点击提交时,才与后台交互
function Submit() {
if ($("#LoginName").val() == "") {
layer.tips('请输入登录账号!', "#LoginName", { tips: [2, '#FF5722'], time: 4000 });
$("#LoginName").focus();
return false;
}
if ($("#LoginPassword").val() == "") {
layer.tips('请输入登录密码!', "#LoginPassword", { tips: [2, '#FF5722'], time:4000 });
$("#LoginPassword").focus();
return false;
}
$.ajax({
Asynch: true,
type: "post",
cache: false,
...
success: function (result) {
if (result.success) {
top.window.location = "/ModuleMain";
}
else {
layer.msg(result.showMsg, { icon: 5, time: 1000 });
}
}
});
}