用户登录验证

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<script src="jq.js"></script>
<style>
{ color:}
</style>
<body>
<form>
<div><label>用户名:</label><input id="username" type="text"/></div>
<div><label>密码:</label><input id="password" type="password"/></div>
<div><input id="sian" type="button" value="登录"></div>
</form>
<script>
$(document).ready(function(e) {
$("#sian").click(function(){
var username=$.trim($("#username").val());
var password =$.trim($("#password").val());
if(username==""){
alert('用户名不能为空');
return false;
}else if(password == ''||password.length<6||password.length>12){
alert('密码必须填写.密码大于6小于12');
return false;
}
$.ajax({
url : "/index.php/Feedback/login.html",
type : "POST",
data : {'username':username,'password':password},
success: function(d){
if(d.type == 'ok'){
alert('登录成功');
window.location.reload();
}else{
alert(d.msg);
}
}
});
});
});
</script>
</body>
</html>

posted @ 2017-11-05 13:39  赵新峰  阅读(292)  评论(0)    收藏  举报