Skip to Content
NFSFU234FormValidation v3 is here — file upload validation, config-driven rules, and more.
v3 (current)restrictInputWithCounter

restrictInputWithCounter

Wires a live character counter to an input/textarea, and (depending on options) restricts further input once the limit is reached. Returns: any

ParameterTypeRequiredDefaultDescription
inputElement`HTMLInputElement \HTMLTextAreaElement`required-
counterContainerHTMLElementrequired-The element that displays the current/remaining character count.
optionsanyoptional{}Configuration such as the max length and counter display format. Defaults to {}.
Usage
Example: Use restrictInputWithCounter
const inputElement = document.getElementById('additionalInfo'); const counterContainer = document.getElementById('counterContainer'); const options = { maxLength: 150, minLength: 10, shouldButtonDisable: true, formId: 'myForm' }; nfsfu234FormValidation.restrictInputWithCounter(inputElement, counterContainer, options);
Last updated on