<!DOCTYPE html>
<html>
<head>
<meta charset="GBK">
<title>登录</title>
<script type="text/javascript" src="/office/js/jquery-1.9.1.js"></script>
<script type="text/javascript" src="/office/js/jquery。validate.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#login").validate({
//自定义验证规则
rules:{
userName:{required:true},
password:{required:true}
},
//自定义提示信息
/* messages:{
userName:{required:"请输入你的用户名"},
password:{required:"请输入密码"}
}, */
//定义错误信息提示位置
errorPlacement:function(error,element){
error.appendTo(".tip");
// error.appendTo(element.parent());
}
});
});
</script>
</head>
<body>
<div style="width:400px;height:250px;margin:15% auto;background:#e8f4ff;">
<div style="winth:100%;height:15%;"></div>
<form id="login" name="login" method="post" action="login.php">
<table style="width:100%;height:200px">
<tr >
<td align="right">用户名:</td>
<td><input name="userName" type="text" id="userName" onmouseover="this.style.backgroundColor='#ffffff'" onMouseOut="this.style.backgroundColor='#e8f4ff'" size="15" /></td>
</tr>
<tr>
<td align="right">密码:</td>
<td><input name="password" type="password" id="password" onmouseover="this.style.backgroundColor='#ffffff'" onMouseOut="this.style.backgroundColor='#e8f4ff'" size="15" /></td>
</tr>
<tr>
<td></td>
<td><span class="tip"></span></td>
</tr><tr>
<td></td>
<td><input type="submit" value="登录" name="submit" /> <input type="reset" value="重置" name="reset" /></td>
</tr>
</table>
</form>
</div>
</body>
这段代码哪里错了,为什么不进行验证就提交了呢
狗要绿豆冰
相关分类