This code is copied from another file and it works in that file, I have checked the variable and form id and i am sure that the name is consistent with the js code. The textbox in genFrom is also validate working, only the checkbox is not working.
<script src="http://code.jquery.com/jquery-1.6.1.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script>
<script>
$(document).ready(function(){
$("#genForm").validate();
$("#genForm").validate( {
rules: {
agree: {
required: true
}
}
})
});
</script>
<form id="genForm" method="post" action="verify.php">
<div class="container">
<div class="hero-unit">
<h1>Subscribe for final</h1>
</div>
<div class="clearfix">
<label>Email</label>
<div class="input">
<input name="Email" type="text" class='required'>
</div>
</div>
<br>
<br>
<div class="clearfix">
<label>Agreements:</label>
<div class="input">
<ul class="inputs-list">
<li>
I accept the terms and conditions.
<!-- Check box is here, not working -->
<input type="checkbox" name="agree" value="1">
</li>
</ul>
</div>
</div>
<br>
<input class="btn primary" type="submit" value="Submit">
</form>
For some reason, you’re calling
validate()twice on the same form, you only need one:Demo: http://jsfiddle.net/8MV5F/
Calling
validate()with no params does have some (configurable) default behavior, one of which is attaching therequiredrule to elements withclass='required', which is why the email field was working. You can also use therequiredattribute for that, and in addition you can usetype="email"to validate as an email address without specifying it in your rules.Here’s a simple example: http://jsfiddle.net/8MV5F/2/
This has the advantage of falling back to native browser validation if supported, in case javascript is disabled, or even just broken.