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

restrictInputWithCounter

The restrictInputWithCounter function serves as an alias to restrictInputLengthWithCounter, providing an alternative method to achieve the same functionality of restricting input length and updating a character counter.

Works in: HTML5, React JS

ParameterTypeDefaultDescription
inputElementHTMLInputElement | HTMLTextAreaElementundefinedThe HTML input or textarea element to restrict.
counterContainerHTMLElementundefinedThe container to display the character count.
optionsobject{}Optional configuration object.

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