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

Fix pattern support #1

Merged
merged 1 commit into from
Jun 3, 2017
Merged

Fix pattern support #1

merged 1 commit into from
Jun 3, 2017

Conversation

tumpio
Copy link

@tumpio tumpio commented Jun 3, 2017

This pull request fixes the HTML5 input pattern support. Each time a tag is inserted the validity of the base.input is verified. On tags-input init, the base.input is first filled with the value. Without this the base.input validation would be done against an empty value.

Original PR by @thomasdegry
developit#23

@pirxpilot pirxpilot merged commit 4607e8d into pirxpilot:next Jun 3, 2017
@pirxpilot
Copy link
Owner

Thanks. Released as 2.1.6

@tumpio
Copy link
Author

tumpio commented Jun 5, 2017

The input validation is still problematic. The original input holds the value of all tags e.g. (tag1,tag2,tag3). If I define a pattern attribute for the input this is now applied to both the whole input and the individual tags. And also if the input type is for example email or url it would cause the whole input to have invalid value if having more than one tag inserted.

I think this could be fixed by removing the pattern attribute from the original input and changing its type to text. What do you think?

@pirxpilot
Copy link
Owner

pirxpilot commented Jun 5, 2017

Makes sense. I'll gladly review any PRs you send my way.

Does it matter though? Especially if we never actually trigger validate the original input field? (It might matter, I am just surprised I never bumped into it - probably using it in a different way)

BTW: for email we could also use multiple but that does not help with pattern, or URL...

@tumpio
Copy link
Author

tumpio commented Jun 6, 2017

It's a problem when using it together with standard HTML forms and HTML validation. Form submit triggers the input validation. Another possible way is to set the type of the original input to 'hidden' in tags-input initialization. That excludes it from the form submit validation. Also the 'required' attribute should not be copied over to the tag insert input because that also makes the form invalid when the tag has been inserted and the tag input field value has been cleared.

It depends mostly how you expect to validate the whole tags input value and the individual values of tags. For example when defining the input field validation attributes (required, pattern, maxlength etc.), should they apply to both whole tags value or single values of tags? Currently they are treated as same. Just my thoughts..

@pirxpilot
Copy link
Owner

Yup - that's exactly it: it's been a while since I have been using form in a way it was apparently intended.
I am all for fixing it. I think it would be cleaner, if validation related attributes apply to a single tag, and not to the ultimate value. Might be good to add a form to our example/demo to see how it's failing now.

Again: since I am not using tags-input in this way I am probably not the best person to tackle it, but I'll gladly help reviewing and releasing fix.

@tumpio tumpio mentioned this pull request Jul 2, 2017
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

Successfully merging this pull request may close these issues.

2 participants