I am wanting to restrict the input characters for a text box to [a-z0-9_-]. However whenever if do this buttons like backspace and the arrow keys don\'t work. I have found s
You can press any key you like, as long as you keep the value from including anything not in the white-list.
inputelement.onkeyup=function(e){ e=e || window.event; var who=e.target || e.srcElement; who.value= who.value.replace(/[^\w-]+/g,''); }