victorjonsson / jQuery-Form-Validator

[DISCONTINUED] jQuery plugin that makes it easy to validate user input while keeping your HTML markup clean from javascript code.
972 stars 476 forks source link

Is $.formUtils.addValidator usable with non input elements? #629

Open sisao opened 7 years ago

sisao commented 7 years ago

I would like to build a custom validator which should contain multiple input elements, but I want to add the data-validation attribute to a div which wraps the inputs.... Is this going to work?

victorjonsson commented 7 years ago

No, you can't use a hidden input? Like:

<form>
  <div id="wrapper">
   text content
   <input type="hidden" data-validation="alphanumeric" value="text content">
  </div>
  </form>

  <script>
    $.validate({
      validateHiddenInputs: true
    });

    $('#wrapper input').validate(function (isValid) {
      console.log('isvalid');
    }); 
  </script>
sisao commented 7 years ago

Yeah, thx, this will do it...