From fbd5e4b0a2cd29bd5b71c3a2202db2dc75104a7b Mon Sep 17 00:00:00 2001 From: Corey Mayo Date: Tue, 6 Oct 2015 16:27:46 -0400 Subject: [PATCH] optional maxlength attribute on input tag --- README.markdown | 5 +++++ js/tag-it.js | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/README.markdown b/README.markdown index c2a16ba5..77b3b1c7 100644 --- a/README.markdown +++ b/README.markdown @@ -167,6 +167,11 @@ Optionally set a *placeholder* attribute on the `input` that gets created for ta Defaults to *null* +### maxTagLength (integer) +Optionally set a *maxlength* attribute on the tag-it `input` that gets created. + +Defaults to *null* + ## Events diff --git a/js/tag-it.js b/js/tag-it.js index 078c264f..15e145aa 100644 --- a/js/tag-it.js +++ b/js/tag-it.js @@ -94,6 +94,9 @@ onTagClicked : null, onTagLimitExceeded : null, + // Optionally set a maxlength attribute on the tag-it input + maxTagLength: null, + // DEPRECATED: // @@ -136,6 +139,10 @@ this.tagInput.attr('placeholder', this.options.placeholderText); } + if (this.options.maxTagLength) { + this.tagInput.attr('maxlength', this.options.maxTagLength); + } + if (!this.options.autocomplete.source) { this.options.autocomplete.source = function(search, showChoices) { var filter = search.term.toLowerCase();