submitHandler

submitHandler

Hi,
I am new to jquery and I am editing a website form. In the form it has something like this
  1. var handleRegister = function () {
  2. ....
  3. ...
  4. ...
  5.          $('.register-form').validate({
  6.            errorElement: 'span', //default input error message container
  7.            errorClass: 'help-block', // default input error message class
  8.            focusInvalid: false, // do not focus the last invalid input
  9.            ignore: "",
  10.            rules: {
  11.                
  12.                fullname: {
  13.                    required: true
  14.                },
  15.                email: {
  16.                    required: true,
  17.                    email: true
  18.                },

  19.                tnc: {
  20.                    required: true
  21.                }
  22.            },

  23.            messages: { // custom messages for radio buttons and checkboxes
  24.                tnc: {
  25.                    required: "Please accept TNC first."
  26.                }
  27.            },

  28.            invalidHandler: function (event, validator) { //display error alert on form submit   

  29.            },

  30.            highlight: function (element) { // hightlight error inputs
  31.                $(element)
  32.                    .closest('.form-group').addClass('has-error'); // set error class to the control group
  33.            },

  34.            success: function (label) {
  35.                label.closest('.form-group').removeClass('has-error');
  36.                label.remove();
  37.            },

  38.            errorPlacement: function (error, element) {
  39.                if (element.attr("name") == "tnc") { // insert checkbox errors after the container                  
  40.                    error.insertAfter($('#register_tnc_error'));
  41.                } else if (element.closest('.input-icon').size() === 1) {
  42.                    error.insertAfter(element.closest('.input-icon'));
  43.                } else {
  44.                 error.insertAfter(element);
  45.                }
  46.            },

  47.            submitHandler: function (form) {
  48.                 form.submit();
  49.            }
  50.        });

  51. $('.register-form input').keypress(function (e) {
  52.            if (e.which == 13) {
  53.                if ($('.register-form').validate().form()) {
  54.                    $('.register-form').submit();
  55.                }
  56.                return false;
  57.            }
  58.        });
  59. }
As far as i can make out from this code is that it validates the form and if no error found it submits the form as per form action. Instead of this i would like to submit  the form through jquery and process the form in php page and revert back if error found and display the error.

Thanks & Regard,
Samir