The input attribute is number, and maxlength does not work. How to solve it?

<input type="text" maxlength="5" /> The effect is ok, when <input type="number" maxlength="5" /> maxlength is invalid, and the length can be input infinitely.

liberation plan:

<input type="number" oninput="if(value.length>5)value=value.slice(0,5)" />

It's easy, get it done!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325946426&siteId=291194637