Name

toLowerCase(), toUpperCase() — NN 2 IE J1 ECMA 1

Synopsis

Returns a copy of the current string in all lowercase or uppercase letters. If you want to replace the current string with a case-adjusted version, assign the result of the method to the same string:

myString = myString.toUpperCase()

It is common to use either one of these methods to create a case-insensitive comparison of two strings. This is especially convenient if one of the strings being compared is entered by a user, who may submit a variety of case situations:

if (document.forms[0].entry.value.toLowerCase() == compareValue) {
    ...
}

Returned Value

String.

Parameters

None.

Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.