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

Limit the length of a tag name #245

Closed
jasoncharnes opened this issue May 27, 2019 · 5 comments
Closed

Limit the length of a tag name #245

jasoncharnes opened this issue May 27, 2019 · 5 comments

Comments

@jasoncharnes
Copy link

Good afternoon! Thank you for Tagify. It is a beautiful addition to our application.

I'm looking to limit the length of a given tag name to n characters. I tried using a regular expression piped to pattern and found no luck.

new Tagify(input, {
  pattern: /^.{1,70}/
}

My apologies, as I might misunderstand the use of pattern

Is there a way to limit the length of a tag? If so, would you mind pointing me in the right direction?

Thank you for your time.

@yairEO
Copy link
Owner

yairEO commented May 27, 2019

Hi! thanks you very much for the kind words :)

You can use the setting transformTag to achieve that, seen in this example.

@jasoncharnes
Copy link
Author

This works great. Thanks, again!

@yairEO
Copy link
Owner

yairEO commented Jun 6, 2019

See demo page, using this /^.{0,20}$/ pattern.

You could also do it via CSS, adding to the Tagify rule .tagify__tag-text{...}

@eugenetraction
Copy link

eugenetraction commented Jul 23, 2020

I implemented a tag max length by ignoring the user after they reached the max length

tagify.DOM.input.addEventListener('keydown', function(e) {
  if (tagify.state.dropdown.visible && tagify.state.tag.value.length >= TAG_MAX_LENGTH) {
    e.preventDefault();
  }
}

@FatihYilmaz06
Copy link

This soluiton works .

$(".tagify").tagify({
// etiketin max uzunlugu
pattern: /^[A-Za-z_✲ ]{1,50}$/,
});

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