Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery validation not stopping form from being submitted
    text
    copied!<p>I'm tearing my hair out here trying to get a jquery validation to play nicely with my form.</p> <p>The validation does not appear to be working. The form just submits itself to the page. I can briefly see the validation error messages appearing before the page submits...</p> <p>My code:</p> <pre><code>//HTML form &lt;form id="form_scheduleEvent" name="form_scheduleEvent"&gt; &lt;label for="name"&gt;Name:&lt;/label&gt;&lt;input class="short" type="text" name="name" id="name" /&gt; &lt;label for="address"&gt;Address:&lt;/label&gt;&lt;input type="text" name="address" id="address" /&gt; &lt;label for="phone"&gt;Phone:&lt;/label&gt;&lt;input type="text" name="phone" id="phone" /&gt; &lt;label for="comments"&gt;Comments:&lt;/label&gt;&lt;textarea name="comments" id="comments" /&gt;&lt;/textarea&gt; &lt;input type="submit" id="submitRequest" value="Add"/&gt; &lt;/form&gt; //jquery //Validation rules $('#form_scheduleEvent').validate({ rules: { name : {required: true, maxlength: 45}, address : {required: true, maxlength: 45}, phone : "required" } }); $('#submitRequest').click(function(){ $.ajax({ type: "POST", url: "common/ajax_event.php", data: formSerialized, timeout:3000, error:function(){alert('Error');}, success: function() {alert('It worked!');} }); return false; }); </code></pre> <p>I tried updating to the latest version of both jquery and jquery.validation....</p> <p>Any help would be appreciated! Thanks.</p> <p><strong>Update</strong></p> <pre><code>//The validation is working, but I can't even get the alert to show.... $('#form_scheduleEvent').validate({ rules: { name : {required: true, maxlength: 45}, address : {required: true, maxlength: 45}, phone : "required", submitHandler: function(){ alert('test'); } } }); </code></pre>
 

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