zhouzi / GentleForm

Accessible and user-friendly HTML5 form validation library.
http://codepen.io/Zhouzi/full/QbBzZp/
MIT License
36 stars 3 forks source link

How to manually trigger an error? #10

Open badpenguin opened 6 years ago

badpenguin commented 6 years ago

I want to do additional checkes when the form isValid, i.e. like when validating a multiple checkbox list. Is there a way to trigger an error and have the error box appear?

zhouzi commented 6 years ago

There is currently no way to add custom validators. The only supported ones are the ones from the HTML5 specification.

But your suggestion makes total sense and I'm willing to add that to the API. I'll need to think about it a bit, perhaps there's a way to add validators to the HTML5 API. In any case, I'll need to think about validation: when and how it should happen for custom validators.

badpenguin commented 6 years ago

@Zhouzi actually the scenario is when you have field that depend on other field's value or, as in may use case, when you have multiple checkboxes and at least 1 must be checked.