Posted By

porquero on 11/09/13


Tagged

javascript number input backspace


Versions (?)

Avoid history back when is pressed backspace key in number imput


 / Published in: jQuery
 

Avoid history back when is pressed backspace key in number imput

  1. $('input[type=number]').on('keydown', function(e) {
  2. var key = e.which || e.keyCode || e.charCode;
  3. if (key === 8) {
  4. var s = $(this).val();
  5. s = s.substring(0, s.length - 1);
  6. $(this).val(s);
  7. return false;
  8. }
  9. });

Report this snippet  

You need to login to post a comment.