Simple enough, why the heck isn't this working...? jQuery 1.6.2 is included in the head as well, above this. It's not triggering validation, now it just goes straight through and says "Submitted" without even validating the fields.
The validation in the head:
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js" type="text/javascript"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/additional-methods.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#newcontract").validate({
rules: {
rec_name: {
required: true
}
},
messages: {
rec_name: {
required: 'You need to enter a contract receiver.'
}
},
submitHandler: function() {
alert("Submitted!"); }
});
});
</script>
Form is named newcontract, so what am I missing:
<form name="newcontract" id="newcontract" method="post">
<input type="text" name="rec_name" id="rec_name" size="42" class="required"/>
<tr><td class="submit" colspan="3"><input type="submit" name="savelisting" id="savelisting" value="Save New Contract" /></td></tr>
</form>
What's going on? It won't validate this text field. Help!!
UPDATE: The code above works as expected. The issue lied within the fact that I removed a table that was wrapping my form, and the validation plugin was skipping the form. As soon as I moved the form outside the table in my HTML, it worked fine.