Answers for "limit input number"

2

limit input characters amount

<p><input placeholder="Title" id="input-title" class="text-input" maxlength="80" onkeyup="count_down(this)"  name="input" ></p>
      <span id="count" style="float: right; font-family: Raleway; font-size:20px; font-weight:600; margin-top:-5px;">80</span><br>

<script>
  function count_down(obj){

    let element = document.getElementById('count');

    element.innerHTML = 80 - obj.value.length;

    if(80 - obj.value.length < 5){
        element.style.color = "firebrick";
    }else{
        element.style.color = "#333";
    }
}
</script>
Posted by: Guest on June-16-2020
0

dont allow user to insert number greater than particular number

function isNumberKey(e) {
    var currentChar = parseInt(String.fromCharCode(e.keyCode), 10);
    if(!isNaN(currentChar)){
        var nextValue = $("#txthour").val() + currentChar; //It's a string concatenation, not an addition

        if(parseInt(nextValue, 10) <= 12) return true;
    }

    return false;
}
Posted by: Guest on April-28-2020
-1

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

Browse Popular Code Answers by Language