Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>.validate()</code> is the method for <em>initializing</em> the plugin. It's not a method of testing the form. Testing is automatic.</p> <p>Therefore, get rid of the <code>click</code> handler. The click event is captured automatically by the plugin. If the form is valid, the <code>submitHandler</code> will fire.</p> <p>Otherwise, you are doing it properly by placing your <code>ajax</code> inside the <code>submitHandler</code> callback.</p> <pre><code>$(document).ready(function () { $('#projectForm').validate({ // initialize the plugin // rules &amp; options submitHandler: function(form) { // ajax method } }); }); </code></pre> <p><strong>Working DEMO: <a href="http://jsfiddle.net/ACdtX/" rel="noreferrer">http://jsfiddle.net/ACdtX/</a></strong></p> <hr> <p>With two different buttons and actions:</p> <p>HTML:</p> <pre><code>&lt;form id="projectForm"&gt; .... &lt;input type="button" class="button" value="TEST" id="test" /&gt; &lt;input type="button" class="button" value="Create" id="create" /&gt; &lt;/form&gt; </code></pre> <p>jQuery:</p> <pre><code>$(document).ready(function () { $('.button').each(function () { $(this).on('click', function () { var action; if ($(this).attr('id') == "test") { action = 'test.php'; } else { action = 'create.php'; } $('#projectForm').submit(); }); }); $('#projectForm').validate({ // initialize the plugin // rules &amp; options submitHandler: function(form) { // ajax method $.ajax({ url: action, // determined from click handler above // ajax options }); } }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload