jQuery Tabs with form submit

jQuery Tabs with form submit

Hello,

I use jQuery tabs to separate some form which I send to the change of tabs. To there no problem.

Now, what I would like to make, it is during the check on server side, if the fields of my form contain errors then the switch does not run and error messages appear and conversely, if there is no error it switch on the tabs selected.

Is there a way to make it?

Here is my current code

//
  1. $('#tabs').tabs({
          select: function(event, ui) {
                var $tabs = $('#tabs').tabs();
                var selected = $tabs.tabs('option', 'selected');
                var clickTab = ui.index;
                var options = {
                        dataType: 'json',
                        beforeSubmit: tabsRequest,
                        success: tabsResponse
                };
                if(selected < 6){
                    $('form#form-tabs'+selected).ajaxSubmit(options);
                    return false;
                } else {
                    return true;
                }
                function tabsRequest() {
                    $("ul.errors").html('');
                }

                function tabsResponse(data){
                      if(data.result == 'success'){
                        if(data.id) {
                            $('input.id-tourisme').removeAttr('value');
                            $('input.id-tourisme').attr('value', data.id);
                        }
                      } else {
                        $.each(data.errors, function(i, error){
                            $('<li>'+ error.message +'</li>').appendTo("ul."+ error.type);
                        });
                    }
                }
          }   
    });

































//

Thank you in advance