Jquery validation multiple tabs, validate one at a time?

前端 未结 2 907
青春惊慌失措
青春惊慌失措 2020-12-08 22:58

I\'m new to jQuery and I\'m trying to use it and the validation plugin (http://docs.jquery.com/Plugins/Validation) to create a multi-part form with multiple tabs for differe

2条回答
  •  温柔的废话
    2020-12-08 23:33

    The existing code didn't work for me (maybe it's dated) so i came up with the following. This example is assuming using jquery tabs and jquery validator.

    $('#tabs').tabs(
    {
        beforeActivate: function( event, ui )
        {   
            var valid = $("#myForm").valid();
            if (!valid) {
                validator.focusInvalid();
                return false;
            }
            else
                return true;
        }
    });
    

提交回复
热议问题