Nov 10 2009

OnKeyUp Fix Alphanumerical Chars

Category: Html,Java ScriptGiulio Pons @ 1:54 pm

When you have an html form and you want only alphanumerical [a-z0-9] chars in your input, you can use this small piece of code in the onkeyup attribute. It will strip non alphanumerical characters while they are typed in a input text box.

<form>
<input type='text' onkeyup="this.value = this.value.replace(/[^a-z0-9]/gi,"");" />
</form>
  • Share/Bookmark

Tags: , ,