Link to home
Start Free TrialLog in
Avatar of alcani
alcani

asked on

lower to upper case

Hi experts,

Could you please provide a simple script to change lower to upper case for each field in a html form?

Regards,
Avatar of Ivo Stoykov
Ivo Stoykov
Flag of Bulgaria image

Here is a variation:
    var inp = document.getElementsByTagName("input");
    for (var x = 0; x < inp.length; x++) {
        if (inp[x].getAttribute("type") != "text") {
            continue;
        }
        inp[x].value = inp[x].value.toLowerCase();
    }

Open in new window

hth

Ivo Stoykov
Avatar of Scott Fell
In css here is a working sample using a class you can attach to any element (div, p, span, li) http://jsbin.com/eferow/1/edit

code
<!DOCTYPE html>
<html>
<head>
  <style>
    .lowercase{text-transform: lowercase;}
  </style>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  <div><span class="lowercase">CONVERT THIS,</span> NOT THIS</div>
</body>
</html>

Open in new window


Serverside languages will have this property as well.  If you need to do mixed case, doing this serverside might be better, but this is quick and easy.
Easy one Using Style:
<input type="text" name="name" id="name" onBlur="this.style.textTransform='uppercase';">

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of dimmergeek
dimmergeek
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks!