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

Validate inputs outside form #2184

Closed
webestet opened this issue Jun 22, 2018 · 3 comments
Closed

Validate inputs outside form #2184

webestet opened this issue Jun 22, 2018 · 3 comments

Comments

@webestet
Copy link

I have few inputs outside my validate forms, but every input have attr form="my-form".
I have this code:

form.validate({ rules: { my_outsude_input: 'required' } });
This don't work.

But .form.validate().element($(my_outsude_input)) this work.
Hovewer my_outsude_input invalid, I call form.valid() and get true...
Also .form.validate().element don't destroy keyup or focusout event when my_outsude_input valid.

How can I do this?

@thanateros
Copy link

I also experience this issue; because of my page layout I would need to put the entire page itself inside a form tag and that majorly screws up my styling for the myriad elements that have nothing to do with the form; I was, therefore, elated to discover I could associate all these form elements outside of a form tag and it would not jack up my styling.

If I don't attempt javascript validation and just submit the form it works exactly as if I had all input elements inside of a form tag --- perfect!

But... if I attempt to use this validation library, it just submits my form without any validation happening and no errors, even with invalid data. If it place a few inside the form tag surrounding my submit button, then those get triggered for validation.

So, it seems kinda misleading to advertise this as a 'form validation library' when it demonstrably is not; it is just and only a validation library for pre-HTML5 forms (since the form= attribute is part of HTML5).

I banged my head against this for 2 days before I came across this ticket and realized I wasn't the only one having this issue. Time to go look for a validation library that actually meets the full HTML5 form specification. I'm so disappointed; I had such high hopes.

@RobJohnston
Copy link
Contributor

Sounds like a duplicate of #2156?

@Arkni
Copy link
Member

Arkni commented Aug 7, 2018

Closing as duplicate of #2156

Thanks @RobJohnston for noticing!

@Arkni Arkni closed this as completed Aug 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants