$('input').on('keydown',function(e){ var keycode = e.which || e.keyCode; if(keycode == 8){ e.preventDefault(); e.stopPropgation(); var str = $(e.currentTarget).val(); $(e.currentTarget).val(str.substr(0,str.length-1)) } })