views:

788

answers:

2

i have from and i am using jquery validate jquery.validate.pack.js

its work fine when i press submit button, i just add following code

            $(document).ready(function(){
        $("#contactform").validate();
            });

and class="validate" for text box

but i want to call php file with Ajax after validate is complete.

like $.ajax({ type: "POST", url: "email_feedback.php", etc

how can i do this ?

Thanks

+3  A: 

See the submitHandler callback option in http://docs.jquery.com/Plugins/Validation/validate#options

$("#contactform").validate({
   submitHandler: function(form) {
    //$(form).ajaxSubmit(); // for the default ajax submission behavior
     $.ajax({ type: "POST", url: "email_feedback.php"})//, etc... for your own
   }
})
Michael Greene
A: 

This will submit the form to the URL that is in the action attribute of the form via AJAX though:

$("#contactform").validate({
   submitHandler: function(form) {
    $(form).ajaxSubmit();
   }
})

Here's an additional link for you as well: http://www.malsup.com/jquery/form/#api

Thanks, Orokusaki

orokusaki