Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check validity of form #80

Closed
ghost opened this issue Jul 27, 2018 · 3 comments
Closed

Check validity of form #80

ghost opened this issue Jul 27, 2018 · 3 comments
Labels

Comments

@ghost
Copy link

ghost commented Jul 27, 2018

Is it possible to check the validity of the form as a whole? I've had a look through the documentation and can't find what I need. If not then I'm assuming I would have to loop through all the fields and check each one?

@Boldewyn
Copy link
Contributor

Yes. You can do a

hyperform.checkValidity(my_form)

which is basically the same as what you'd expect: https://github.com/hyperform/hyperform/blob/master/src/polyfills/checkValidity.js#L15

The canonical call is

my_form.checkValidity()

which is supported, too, and works according to the specification.

I'm keeping the issue open, because you're right, I haven't mentioned that in the docs, which I need to fix.

@ghost
Copy link
Author

ghost commented Jul 27, 2018

Thanks, unfortunately it doesn't work in my use case (which admittedly, looks like an edge case). I have a long form which I'm splitting out into chunks, I want to validate each chunk before showing the next one so my element is a div rather than a form (to avoid validating fields which aren't even displayed yet).

@Boldewyn
Copy link
Contributor

Boldewyn commented Jul 27, 2018

HTML has you covered there, too :-)

If you can, use a <fieldset> for each section. Fieldsets have a checkValidity() method, too.

Edit: Hm. From looking at the code, it could be, that Hyperform doesn't fully support fielset.checkValidity() at the moment. I'll have to check. If you do that, too, and find problems, it'd be great, if you'd open a new ticket for that.

Boldewyn added a commit to hyperform/hyperform.github.io that referenced this issue Aug 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant