Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your <code>ajax</code> is running on page load because nothing is stopping it. You need to put the <code>ajax</code> code inside an event handler so it's only called if/when your form passes validation.</p> <p>The following is an example of the proper implementation of the Validation Plugin. And you do not need to put the <code>validate()</code> inside a click handler. The Validation plugin has a bunch of its own handlers built in including a <code>submitHandler</code> that fires when the form passes validation.</p> <pre><code>&lt;script type='text/javascript'&gt; $(document).ready(function() { jQuery.validator.addMethod("math", function(value, element, params) { return this.optional(element) || value == params[0] + params[1]; }, jQuery.format("Please enter the correct value for {0} + {1}") ); $('form').validate({ rules { // your rules }, submitHandler: function(form) { $.ajax({ // your ajax parameters }); return false; } }); }); &lt;/script&gt; </code></pre> <p><a href="http://docs.jquery.com/Plugins/Validation" rel="nofollow">Validation Plugin Documentation</a></p> <p>Some side issues...</p> <ol> <li><p>Your code would be much easier to read &amp; troubleshoot if you used proper indentation and standard formatting.</p></li> <li><p>There is not need to use duplicate <code>document.ready</code> functions. Everything can be inside one.</p></li> <li><p>Like in #2, you do not need separate sets of <code>&lt;script&gt;&lt;/script&gt;</code> tags to contain your code. Everything can be enclosed once.</p></li> </ol>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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