I have a quite perflexing problem that I have researched and come up blank;
Scenario: I have a form, with the jQuery bassistance.de's validate() plugin (http://docs.jquery.com/Plugins/Validation).
Does the job on submit perfectly, however; I two types of submit button.
One submits the form as usual, triggering my back-end validation and return errors or success.
The other type, is to all intense and purposes a submit button to the browser, however it tells my back-end to add another section of inputs (ie, a repeating element for employment history.) I want the user to be able to add the repeating elements without having to complete the rest of the form first. So clicking the second type of submit I want to BYPASS the validate();
HTML:
<form method="post" action="" id="ApplicationForm" name="ApplicationForm">
<input id="job1" name="job1" class="required"/>
<input type="submit" name="delete_job1" value="Delete" class="delete" />
<input id="job2" name="job2" class="required"/>
<input type="submit" name="delete_job2" value="Delete" class="delete" />
<input type="submit" name="add_job" value="Add Job" class="add" />
<input type="submit" name="ApplicationForm" value="Save Details" class="submit" />
</form>
I have tried a listener for the true submit button below, but this just stops the validate all togerther;
$(document).ready(function()
{
var submitPress
$(".submit").click(function()
{
submitPress = true;
});
if (submitPress)
{
$('form#ApplicationForm').validate();
}
});
I guess this is because the validate(); listeners is setup on the initial loading of the page, not upon submit...
Is there there a rule or setting for validate(); I am missing, that I could utilise, or even a good hack with good old fasioned JS.
Muchos gratias who ever can help, i'm at my whits end.
Yours Sincerely, Working Late, AGAIN , Developer
http://docs.jquery.com/Plugins/Validation/Reference#Skipping_validation_on_submit
basically, add class="cancel"
to the submit buttons which you don't want to trigger validation.
<input type="submit" value="I Validate" />
<input type="submit" class="cancel" value="I skip Validation" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With