Capitalize Input Text In Javascript
In a form, I have two buttons to transform text to uppercase and lowercase. I am using this function to transform input text to upper case: document.xyz.textinput.value=document.xy
Solution 1:
Try This:
document.xyz.textinput.value = document.xyz.textinput.charAt(0).toUpperCase() + document.xyz.textinput.slice(1);
If you want a capitalize functions, See here.
Solution 2:
CSS has some text-transform properties too: https://developer.mozilla.org/en/CSS/text-transform
If that isnt an option, you can simply split your string by each whitespace and capitalize that word.
Post a Comment for "Capitalize Input Text In Javascript"