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

pattern= doesn't seem to work as expected #20

Open
mikemaccana opened this issue Jan 18, 2017 · 2 comments
Open

pattern= doesn't seem to work as expected #20

mikemaccana opened this issue Jan 18, 2017 · 2 comments

Comments

@mikemaccana
Copy link
Contributor

See jsfiddle at http://jsfiddle.net/d5w4jpxq/71/ :

<input name="hashtags" type="tags" pattern="^#" placeholder="#hashtags">

Still allows data that doesn't start with a hash to be entered. The docs mention HTML5 pattern support - should we use pattern to limit the input or should we do this via change events?

@mikemaccana
Copy link
Contributor Author

PS - thankyou Jason!

@mikemaccana mikemaccana changed the title placeholder= doesn't seem to workas expected pattern= doesn't seem to work as expected Jan 18, 2017
@developit
Copy link
Owner

@mikemaccana Looks like there were actually a few copies of tags-input.js on that page and the one being used didn't have a placeholder defined. I've modified it to just use one copy. Also the placeholder attribute is a pre-anchored regex, so the pattern was invalid. Here's an example with a valid placeholder and some CSS to show validation state:

http://jsfiddle.net/developit/nL1h3dwk/

However, you're right - the field gets marked as invalid like we would expect, but tags-input doesn't care and happily adds the tag. The fix here should be pretty simple - we need to have the method that commits a tag from the input field first check that input.validity.valid is true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants