Skip to content

Commit feea47b

Browse files
ractoont3mujin
authored andcommitted
README update
1 parent de34af8 commit feea47b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

textcounter.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@
6868
base.$container.text('error: [maxlength] attribute not set');
6969
}
7070
}
71+
else if (base.options.max == 'autocustom') {
72+
var max = base.$el.attr(base.options.autoCustomAttr);
73+
74+
if (typeof max !== 'undefined' && max !== false) {
75+
base.options.max = max;
76+
}
77+
else {
78+
base.$container.text('error: [' + base.options.autoCustomAttr + '] attribute not set');
79+
}
80+
}
7181

7282
// if this is a countdown counter deduct from the max characters/words
7383
textTotalCount = base.options.countDown ? base.options.max - textCount : textCount;
@@ -294,7 +304,8 @@
294304
$.textcounter.defaultOptions = {
295305
'type' : "character", // "character" or "word"
296306
'min' : 0, // minimum number of characters/words
297-
'max' : 200, // maximum number of characters/words, -1 for unlimited, 'auto' to use maxlength attribute
307+
'max' : 200, // maximum number of characters/words, -1 for unlimited, 'auto' to use maxlength attribute, 'autocustom' to use a custom attribute for the length (must)
308+
'autoCustomAttr' : "counterlimit", // custom attribute name with the counter limit if the max is 'autocustom'
298309
'countContainerElement' : "div", // HTML element to wrap the text count in
299310
'countContainerClass' : "text-count-wrapper", // class applied to the countContainerElement
300311
'textCountMessageClass' : "text-count-message", // class applied to the counter message

0 commit comments

Comments
 (0)