Html, Tutorial

Maxlength for Input Type=”number” in Chrome

Less than a minute to read

There are several ways that can be copied from the following references: https://stackoverflow.com/questions/18510845/maxlength-ignored-for-input-type-number-in-chrome I used the following code.
For a maximum of 16 digits in the form for filling in the Population Identification Number (KTP).

<div class="form-group">
<label><b>NOMOR INDUK KTP</b></label>
<input type="number" pattern="/^-?\d+\.?\d*$/" onKeyPress="if(this.value.length==16) return false;" / class="form-control" name="nik_ktp" placeholder="" required>
</div>

Good luck.


Leave a Reply

Your email address will not be published. Required fields are marked *

× Chat