What is the best way to limit text input entry to numbers, lowercase letters, and certain symbols?

Posted by Adam Maras on Stack Overflow See other posts from Stack Overflow or by Adam Maras
Published on 2010-03-24T21:52:59Z Indexed on 2010/03/24 22:03 UTC
Read the original article Hit count: 318

Filed under:
|

Without using jQuery, what is the best way to limit text entry of a textbox to numbers, lowercase letters and a given set of symbols (for example - and _)? If the user enters an uppercase letter, I would like it to be automatically converted to a lowercase letter, and if the user enters a symbol not within the given set, I would like to be able to instantly show a validation error (show some element adjacent to or below the text box).

What's the cleanest cross-browser way of doing this without the aid of jQuery?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about not-jquery