How do I make all of the characters of a text box lowercase as the user types them into a text field in Javascript?
Does it only have to display in lowercase, or does it have to be lowercase? If you want to display lowercase, you can use CSS text-transform: lowercase
.
You need to enforce this constraint server-side anyway, because the user can disable any JS code you put in to enforce that it remains lowercase.
My suggestion: use the CSS text-transform
to make it always display in lowercase, and then do a toLower
or your language's variant of it on the server-side before you use it.