The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Problem with Validating and Ajax Submission Re: Problem with Validating and Ajax Submission


Hello friends,
I was having some problem in validating and submitting the form via AJAX as mentioned above, hence I got it working by setting the options for the ajaxForm() method. In the ‘beforeSubmit’ option I checked for the validation of the code and in the success option I just printed the thank you message..

$(function() {
var options = {
beforeSubmit: function(){
return $(‘#contactForm’).validate().form();
success: function(){

Thanks, message sent successfully! We will get back to you as soon as possible.


// other available options:
//url: url // override for form’s ‘action’ attribute
//type: type // ‘get’ or ‘post’, override for form’s ‘method’ attribute
//dataType: null // ‘xml’, ‘script’, or ‘json’ (expected server response type)
//clearForm: true // clear all form fields after successful submit
//resetForm: true // reset the form after successful submit
// $.ajax options can be used here too, for example:
//timeout: 3000