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> |