Upper and lower case strings with Javascript
Posted September 15th, 2009 in Javascript
I needed to convert a string to lower case the other day with Javascript and wasn't sure of the exact function name, so turned to my blog but was surprised I didn't have a post about how to do this... so here it is now.
Lower case a string with Javascript
Yes, it is as obvious as I thought it was, but making a string lower case isn't something I need to do very often (almost never) which is why I went to look it up. And now that I've written a post about it I'll probably never need to look it up again.
To lower case a string in Javascript
string.toLowerCase()
For example:
alert( "AAA".toLowerCase() );
or
var foo = "AAA"; alert( foo.toLowerCase() );
Both of the above examples will show "aaa" in a alert dialog box.
Upper case a string with Javascript
To upper case a string in Javascript
string.toUpperCase()
For example:
alert( "aaa".toUpperCase() );
or
var foo = "aaa"; alert( foo.toUpperCase() );
Both of the above examples will show "AAA" in a alert dialog box.
Related posts:
- Substrings in Javascript with substring() (Friday, July 24th 2009)
- Substrings in Javascript with substr() (Tuesday, July 21st 2009)
- Get a string's length with Javascript (Friday, July 10th 2009)
- Trimming strings with Javascript (Tuesday, June 16th 2009)
- Multi line strings with Javascript (Tuesday, May 26th 2009)
- Upper case and lower case strings with MySQL (Tuesday, July 29th 2008)
Share or Bookmark
Share or Bookmark this page using the following services. You will need to have an account with the selected service in order to post links or bookmark this page.
Subscribe or Follow
Subscribe via RSS or email, or follow me on Facebook or Twitter below. The RSS icon takes you through to Feedburner where you can select the service or application to use.
