javascript - How to submit a form using jQuery Validate submitHandler -
this jquery submit form code. know how can submit form on using submithandler. in advance.
submithandler: function(form) { // other stuff valid form $.post('thankyou.php', $("#confrom").serialize(), function(data) { $("#confrom").fadeout('fast', function(){ $('#results').html(data); }); }); }
there submithandler built plugin contains form.submit(). since you're over-riding own custom submithandler, still need use submit. otherwise, in case, kind of ajax instead of .submit().
the submithandler goes inside of .validate() method. in order use .validate() method, must first include jquery validate plugin after include jquery.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script src="//ajax.aspnetcdn.com/ajax/jquery.validate/1.13.1/jquery.validate.js"></script> <script> $(document).ready(function() { $('#yourform').validate({ // other options, submithandler: function(form) { // other stuff valid form $.post('thankyou.php', $(form).serialize(), function(data) { $("#confrom").fadeout('fast', function(){ $('#results').html(data); }); }); } }); }); </script>
Comments
Post a Comment