Answers for "how to set a limit of input in javascript"

0

how to limit characters in number input js

function limit(element)
{
    var max_chars = 2;

    if(element.value.length > max_chars) {
        element.value = element.value.substr(0, max_chars);
    }
}


<!-- HTML -->
<input type="number" onkeydown="limit(this);" onkeyup="limit(this);">
Posted by: Guest on April-27-2020
-2

html input number length limit

<!-- The maximum number of characters allowed in the 
<input> element.
 Default value is 524288 -->
<input height="524288" type="button">
Posted by: Guest on September-01-2021

Code answers related to "how to set a limit of input in javascript"

Browse Popular Code Answers by Language