Home : Internet : JavaScript : Text : Lowercase

Convert Text to Lowercase

Converting a text string to lowercase is very easy using the JavaScript toLowercase() method. The following example shows how this works:

This script takes the input from the first text field and outputs it to the second. You can adapt the script to accept and output the string in other ways.

Place the following code in the document head:

function makeLowercase() {
document.form1.outstring.value = document.form1.instring.value.toLowerCase();
}

Place the following code in the document body. This includes two text fields (one for the input and one for the resulting output) and a button to initiate the conversion:

<form name="form1" method="post">
<input name="instring" type="text" value="this is the text string" size="30">
<input type="button" name="Convert" value="Make Lowercase >>" onClick="makeLowercase();">
<input name="outstring" type="text" value="" size="30">
</form>
Subscribe to us on YouTube