useInputCharacterLimit

Track number of input characters typed with useInputCharacterLimit and set your constraint character count.

Install:

npm i @uidotdev/usehooks

Description:

The useInputCharacterLimit hook allows you to track and control the current number of input characters typed inside the form input box. We can set a threshold value for the number of input characters as we desire to set a constraint.

Parameters

NameTypeDescription
currentValuestringThe current state value of the input field.
maxValuenumberThe maximum number of the input field value .
inputRefobjectThe ref object of the input field.

Return Value

The useInputCharacterLimit hook returns an object containing the following elements:

NameTypeDescription
inputValuestringThe current state value of the input field.
isExceedingCountbooleanThe current state of the exceeded count.
currentValueLengthnumberThe length of the current input state value.

Demo:

Example:

More Hooks:

Sort: