Quick Search:
 
 JavaScript: Capitalize first letter of words Jump to:  
Category: >> JavaScript >> Capitalize first letter of words  

<< lastnext >>

Snippet Name: Capitalize first letter of words

Description: Capitalize the first letter of every word entered into a form field.

Comment: (none)

Language: JAVASCRIPT
Highlight Mode: JAVASCRIPT
Last Modified: February 27th, 2009

<SCRIPT LANGUAGE="JAVASCRIPT">
 
FUNCTION capitalizeMe(obj) {
        val = obj.value;
        newVal = '';
        val = val.split(' ');
        FOR(VAR c=0; c < val.length; c++) {
                newVal += val[c].substring(0,1).toUpperCase() +
val[c].substring(1,val[c].length) + ' ';
        }
        obj.value = newVal;
}
 
</SCRIPT>
 
<FORM NAME="TEST">
        <INPUT TYPE="TEXT" NAME="TESTER" onChange="capitalizeMe(this)">
</FORM> 


 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org