0

I have a button like

<button onclick="$('#myForm').submit()>Submit!</button>

which validates all inputs and submits if validated. I have one hidden input that I want validated as well. The inputs inside the form are all validated whenever their value changes, too. What I want to set the validator to validate hidden inputs.

All the examples I see on the internet are like

$("#myform").validate({
   ignore: ":hidden"
});

which invokes the validation which is what I don't want. I want to define what happens whenever it is invoked. Does that make sense?

Sparky
  • 98,165
  • 25
  • 199
  • 285
Questionaire
  • 287
  • 1
  • 8
  • @Wintermute that makes it not submit – Questionaire Jan 11 '18 at 21:17
  • You seem confused. First, the `ignore` option tells it what NOT to validate. So if you set `ignore: ":hidden"`, that is basically the default and hidden elements will NOT be validated. Use `ignore: []` and nothing will be ignored; everything will be validated including hidden elements. – Sparky Jan 12 '18 at 17:21
  • Secondly, when using jQuery, inline JavaScript handlers become obsolete. Besides, you do not need an `onclick` handler inside the `button`... simply use the correct `type` attribute: ``. – Sparky Jan 12 '18 at 17:23

0 Answers0