I use the jQuery plugin https://github.com/victorjonsson/jQuery-Form-Validator together with responsive tabs and a problem arises during validation!

  • Hidden fields seems to be validated. Is that a bug?

  • Is it possible to disabled the validation of a form using this
    plugin?

  • Is it possible to trigger the validation with an input of type
    "button"?

Thank you.

有帮助吗?

解决方案

The plugin tried to validate forms that not visible, and so the validation doesn't pass.

I'm guessing you mean inputs that is hidden. When you hide the input you should also remove, or rename, the attribute data-validation.

Is it possible to remove validation from a form?

Yes, simply remove or rename the attribute data-validation

function removeValidation($form) {
   $form.find('*[data-validation]').attr('data-validation', null);
}

Is it possible for input type to be "button"?

Yes, trigger validation when the button is clicked.

$.validate({
  form : '#my-form',
  onSuccess : function($form) {
     $form.get(0).submit();
  }
});

$('button.my-submit-button').on('click', function() {
  $('#my-form').trigger('submit');
});
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top