谁能告诉我如何使用 jQuery Validate 插件验证登录表单?
我试过这段代码:
<script src="jquery-1.8.3.js"></script>
<script src="loginbut/js/login.js"></script>
<script src="jquery.validate.js" type="text/javascript">
</script>
<script>
$(document).ready(function(){
$("#loginform").validate({
rules:{
//name:"required",
username:"required",
password:"required",
gender:"required",
},
messages:{
email:"This field cannot be empty",
password:{
required:"specify password",
},
});
});
</script>
和html代码为:
<div id="bar">
<div id="container">
<!-- Login Starts Here -->
<div id="loginContainer">
<a href="#" id="loginButton"><span>Login</span><em></em></a>
<div style="clear:both"></div>
<div id="loginBox">
<form id="loginForm">
<fieldset id="body">
<fieldset>
<label for="email">Username</label>
<input type="text" name="email" id="email" class="required"/>
</fieldset>
<fieldset>
<label for="password">Password</label>
<input type="password" name="password" id="password" class="required"/>
</fieldset>
<input type="submit" id="login" value="Sign in" />
<label for="checkbox"><input type="checkbox" id="checkbox" />Remember me</label>
</fieldset>
<span><a href="#">Forgot your password?</a></span>
</form>
</div>
</div>
<!-- Login Ends Here -->
</div>
</div>
验证不起作用。
请帮帮我。