Avoid history back when is pressed backspace key in number imput


/ Published in: jQuery
Save to your folder(s)

Avoid history back when is pressed backspace key in number imput


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.