When I was build the sign-up screen for toepoke I wanted to tidy up the data entry for the player’s name so you get capitalised names.
Thankfully I thought a little bit more and remembered the text-transform property in CSS, and wondered if this would work against text input fields as well as heading and paragraph tags, etc.
Turns out it works quite well, and the above works under most of the modern browsers. Tested and works in Chrome 7,IE 8, FF 3.6, Safari 5, but sadly not Opera 10. Of course the text-transform property is an aesthetic effect, so I can live with it not working in Opera.
Also bear in mind if the user enters their name in lowercase, their name will be in lowercase when the form is posted to the server, so you’ll still need to capitalise on the server-side. Something like the following C# string extension should do the trick. (or see totitle … as kindly pointed at by Maarten van der Lee below):
You can see the above in action on our sign-up page. Naturally this can be extended to use the uppercase and lowercase text-transform rules (uppercase is quite useful for postcodes too).
Hope this proves useful for someone.