I want that people trying to subscribe on my website to enter a nickname and that nickname should exclusively consist of letters and numbers (no special characters at all).
I would like somthing as following : abcdefghijklmnopqrstuvwxyz1234567890
only.
How can I check if it has only those?
with javasacript
source link: http://newsourcemedia.com/blog/javascript-non-alphanumeric-characters-regex/
The HTML5 solution would be...
jsFiddle.
However, for best browser support, you could use JavaScript...
jsFiddle.
To make the JavaScript version similar to the HTML5 method, look at the form's
submit
event.Keep in mind this has a pretty strict definition of letters and numbers. For proper Unicode support, find the ranges you care about and use
\u0000-\uFFFF
to specify it.I suggest to have a look at: RegEx library
It contains a lot of RegEx that you can test directly on the site and change according to your needs.
I always use it as source whenever I need to work with RegEx.