Darshan Kini Darshan Kini - 6 months ago 15
HTML Question

Input field which accept only number with maxlength

<input type="number">


I want take only number from input field with maxlength is 8.please suggest me.

Answer

You could do that with jquery.

$('input[type=number]').keypress(function() {
      if (this.value.length >= 8) {
          return false;
      }
});

you could replace the 'input[type=number]' with either an id or class and add the id or class to the input field.