40818419 / react-code-input

React component for entering and validating PIN code.
MIT License
314 stars 129 forks source link

max-length not valid for input type number #167

Open hobadams opened 2 years ago

hobadams commented 2 years ago

Issue

the max-length property is not valid for input type number.

Screenshot 2022-05-19 at 09 38 45

Solution

Something like this (just an idea).

const textInputs = ['email', 'password', 'search', 'tel', 'text', 'url'];
let maxLength = null

if (textInputs.includes(input.type)) {
maxLength = 'existing logic here'
}