why dont you do the checks before submit?

Example: Inside submit function...

make sure you got a div to display errors:

var err = jQuery('#error');  //<div name="error" id="error"....

 form.submit(function(evt) { //submitting the form

//then check to see if inputs are correct...
  if(form.find('#author')[0]) {
      if(form.find('#author').val() == '') {
                   err.html('<span class="error">Enter Name</span>');
                   return false;
           } // end if
//then check if email is correct...
                if(form.find('#email').val() == '') {
                        err.html('<span class="error">'+enter_email+'</span>');
                        return false;
                } // end if
                var filter  = 
/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-
Z0-9]{2,4})+$/;
                if(!filter.test(form.find('#email').val())) {
                        err.html('<span class="error">'+enter_valid+'</span>');
                        if (evt.preventDefault) {evt.preventDefault();}
      return false;
                } // end if
        } // end if
}); end of submit...

Hope this help alittle =)

Reply via email to