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

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'
}