Skip to content

Instantly share code, notes, and snippets.

@ekka21
Created June 16, 2012 16:23
Show Gist options
  • Save ekka21/2941837 to your computer and use it in GitHub Desktop.
Save ekka21/2941837 to your computer and use it in GitHub Desktop.
jQuery: Form validation, call back function ajax
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js" type="text/javascript" charset="utf-8"></script>
$("#freeform").validate({
submitHandler: function() {
$.ajax({
url: "URL",
type: 'POST',
dataType: 'html',
data: ({
name: $('#name').val(),
email: $('#email').val(),
ff_company: $('#ff_company').val(),
ff_date_needed: $('#ff_date_needed').val(),
ff_street: $('#ff_street').val(),
ff_city: $('#ff_city').val(),
ff_state: $('#ff_state').val(),
ff_zip: $('#ff_zip').val(),
ff_phone: $('#ff_phone').val(),
ff_logo_use: $('#ff_logo_use').val(),
option1000: $('#option1000').val(),
ff_requested_logos: $('#ff_requested_logos').val()
}),
success: function(data){
if (data=="Email sent!"){
alert('EMail sent!');
}else{
alert('Oh no, something went wrong!');
}
}
});
}//submitHandler
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment