Instance Settings
Customise each targetted input field with the settings below (all are optional):
$(selector).maxlength({max: 400});
feedbackTarget | feedbackText | max | onFull | overflowText | showFeedback | truncate
Name | Type | Default | Comments |
---|---|---|---|
max | number | 200 | The maximum number of characters allowed in the textarea. |
truncate | boolean | true | Set to true to truncate any characters after the maximum allowed,
or false to only highlight the overflow. The textarea and the
feedback element are marked with classes to indicate their status:
maxlength-full when at or past the maximum number of characters
and maxlength-overflow when past that maximum.Since 1.0.2. |
showFeedback | boolean or string | true | Set to true to show a countdown of characters used/remaining.
Set to 'active' to only show the feedback when the textarea is hovered or focussed.
Otherwise no feedback is shown. See truncate
for classes applied to the textarea and feedback element to indicate their status.Since 1.0.2 - 'active' added. |
feedbackTarget | string or element or jQuery or function | null | Redirect the feedback to another element on the page - it only has effect if
showFeedback is not false .
Provide either the jQuery selector, the DOM element itself, the element in
a jQuery wrapper, or a function that returns the element within a jQuery wrapper.
Within any callback function, the this value is the current textarea.Since 1.0.2. |
feedbackText | string | '{r} characters remaining ({m} maximum)' | The text to display for feedback to the user. Include substitution points within the text: '{r}' for the number of characters remaining, '{c}' for the number of characters entered, and/or '{m}' for the maximum number of characters allowed. One of the regional settings. |
overflowText | string | '{o} characters too many ({m} maximum)' | The text to display for feedback to the user when there are more characters in the
field than the allowed maximum (see truncate ).
Include substitution points within the text: '{o}' for the number of
characters past the maximum, '{c}' for the number of characters
entered, and/or '{m}' for the maximum number of characters allowed.
One of the regional settings.Since 1.0.2. |
onFull | function | null | This function is called when the textarea is full or overflowing.
It receives one parameter, being a Boolean value indicating that
the text is just full (false) or is overflowing (true).
Since 1.1.0. |