limit input characters amount
snippet in html

max char in input html field

user2860


  
    <form 
    action="/action_page.php">

  <label for="username">Username:</label>
  <input type="text" 
    id="username" name="username" maxlength="10"><br><br>
  <input 
    type="submit" value="Submit">

    </form>
  
 

how to limit input type max length

user737

<input name="somename"
    oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);"
    type = "number"
    maxlength = "6"
 />

limit input characters amount

user9831

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