Put your submit code into the submitHandler-callback. See this demo for an example: http://jquery.bassistance.de/validate/demo/ajaxSubmit-intergration-demo.html
Jörn On Fri, Dec 26, 2008 at 4:50 PM, avances <vance...@gmail.com> wrote: > > I have two scripts, one validates the form and the other enters the > data into a SQL database without a page refresh. Both scripts work > fine on there own... > > How can I combine them so the form validates and then inserts when > form is free of errors. Please see the two scripts below. I suspect it > be very easy but have been searching the net with no luck, > > I am using the validate plugin from jquery. > > <script type"text/javascript"> > > > $(document).ready(function(){ > > > $("#submit").validate ( { > > showErrors: function(errorMap, errorList) { > $("#warning").html("Tu formulario contiene " + > this.numberOfInvalids() + " errores."); > this.defaultShowErrors(); > }, > > debug: false, > errorElement: "em", > errorContainer: $("#warning"), > success: function(label) { > label.text("ok!").addClass("success"); > } > }); > > > $("form#submit").submit(function() { > > // we want to store the values from the form input box, then send via > ajax below > var fname = $('#fname').attr('value'); > > $.ajax({ > type: "POST", > url: "submit_data.php", > data: "fname="+ fname, > beforeSubmit: showRequest, > success: function(del){ > $('td.success').fadeIn(); > $("#extra").hide(); > $("form#quickcheckbox > inp...@name=checkme][type='checkbox']").attr > ('checked', false); > $('#submit').resetForm(); > setTimeout(function() { > $("td.success").hide(); }, 4000); > > } > }); > return false; > }); > > > > }); > > > </script> >