faqts : Computers : Programming : Languages : JavaScript : Forms : TextAreas/TextFields

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

26 of 30 people (87%) answered Yes
Recently 9 of 10 people (90%) answered Yes

Entry

How do I convert the field input to lower/upper case?

Mar 10th, 2000 10:31
Martin Honnen,


For IE4/5 you can do so in the onkeypress handler
http://www.faqts.com/knowledge-base/view.phtml/aid/1661/fid/130/lang/
so any key typed is converted before being made visible.

For other browsers use the onchange handler to convert the input after 
being typed in:
  <INPUT TYPE="text"
         ONCHANGE="this.value = this.value.toUpperCase();"
  >
  <TEXTAREA
      ONCHANGE="this.value = this.value.toLowerCase()"
  >