OnKeyUp Fix Alphanumerical Chars

When you have an html form and you want only alphanumerical [a-z0-9] chars in your input, you can use this…

Novembre 10, 2009

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>

Author

PHP expert. Wordpress plugin and theme developer. Father, Maker, Arduino and ESP8266 enthusiast.

Recommended

Unobtrusive javascript to add an overlay banner

If you have to add an overlay to a site, here is a fast way to do it with an…

Novembre 7, 2011

PHP parse url, mailto, and also twitter’s usernames and arguments

This small function receive a text as input and returns an html text with links if the source text contains…

Marzo 10, 2010

How to capture enter key pressed in a form (JavaScript)

Suppose you have a login form and you want to send the form when user press enter on his keyboard…

Febbraio 16, 2010

Fix html tags, close tags, repair bad quotes and more

This class can solve many problems coming from user generated html content or to fix html content before making some…

Febbraio 3, 2010

The Quantcast CMP broke my sites

A javascript error in CMP blocks my site.

Maggio 19, 2023