views:

403

answers:

2

Hi Guys, 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

+1  A: 

http://docs.jquery.com/Plugins/Validation/Reference#Skipping_validation_on_submit

chris
Cheers Chris, thats the Badger... Don't know how I missed that. Think I entered the twilight zone last night and had to go home.
Will Hancock
A: 

Thanks Chris, that worked... http://docs.jquery.com/Plugins/Validation/Reference#Skipping_validation_on_submit

Next Question... how do I close this bug, or set to answered? My rep is too low to vote on replies...

Will Hancock
I've yet to ask a question here, so I don't know either :) But there's probably a checkmark or something similar near my post.
chris