Capitalize First Letter of Each Word
- Home
- Javascript
- Capitalize First Letter of Each Word
Capitalize the first letter of every word entered into a form field.
<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>
Try it...
asp javascript first letter capitalize forms