Convert text to upper or lower case

To do so, simply make use of the toUpperCase() or toLowerCase() methods. For example:

<input type="text" name="myField" id="myField" size="20" onKeyup="javascript:this.value=this.value.toUpperCase();"> : To Upper

<input type="text" name="myField" id="myField" size="20" onKeyup="javascript:this.value=this.value.toLowerCase();"> : To Lower

Below is the working sample:

 To Upper

 To Lower

If you do not wish to run it for each key-up such as in this example, try the onChange event, which will only fire when the user leaves the input field.

Leave a Reply

Your email address will not be published.