Why did my form start requiring a double click to submit after I added the jquery validation plug in? How do I change it? -
i have submit() event attached form submit button, before started using jquery validation plug in submit form on single click. reason takes second click. how can make go single click?
$("form").submit(function(){ $(".selector").validate({ rules: { performance : { required: true //customvalidation: true }, location : { required: true //customvalidation: true }, date : { required: true //customvalidation: true } }, messages: { performance : { required: "enter show name" //customvalidation: true }, location : { required: "enter location" //customvalidation: true }, date : { required: "pick date" //customvalidation: true } } return false; }); //closes submit() });
this whole problem...
$("form").submit(function(){ $(".selector").validate({ ...
you not need put .validate()
inside of submit
event handler. plugin captures submit
event automatically. .validate()
method initialization method of plugin on form; gets attached form
element , called once on dom ready. (you presently need double-click because takes first click initialize plugin.)
just instead...
$(document).ready(function() { ("#yourform").validate({ // options & rules }); });
simple demo: http://jsfiddle.net/x6ckg/
if, whatever reason, need run other code on submit
event, use submithandler
callback function provided plugin.
$(document).ready(function() { ("#yourform").validate({ //options & rules, submithandler: function (form) { // stuff when form valid // ajax, etc? } }); });
Comments
Post a Comment