form not submitting after javascript validation
I'm trying to bring two pieces of functionality together, form validation and form submission, individually they work fine, the problem arises when I try to combine them. The documentation says that the 'valid' function which verifies if the form has validated must follow the validate call. The problem is that as soon as I include the valid() (
see)(the red block) it stops the form submitting it's data, which normally works.
- $().ready(function() {
// validate the comment form when it is submitted
$("#publishForm").validate({
rules: {
field1: "required",
field2: "required"
},
messages: {
field1: "Please enter field1",
field2: "Please enter field2"
}
});
$("#xxx").click(function() {
alert("Valid: " + $("#publishForm").valid());
return false;
});
});
</head>
<body>
<div id="main">
<form id="publishForm"method="post" action="**" enctype="multipart/form-data" >
<label for="field1">field1</label>
<input id="field1" name="field1" />
<label for="field2">field2</label>
<input id="field2" name="field2" />
<input type="submit" value="Submit" style="padding:8px; width:80px" class="submit"/>
</form>