>>> Programming >> Javascript > Upcase First Letters (This page has been seen 868 times)
How to make upper case of characters with Javascript?
Here is an example on how to set an input text box to upcase every first letter of everyword that is typed
The Code:
The Code:
function TC_UpCaseFirstLetters(InputBox){
var RetValue = "";
var InputStr = InputBox.value;
var InputLen = InputStr.length;
if( InputLen < 1)
return;
if( InputLen == 1 )
RetValue = InputStr.toUpperCase();
else{
SecondLast = InputStr.substring( InputLen - 2, InputLen - 1 );
LastChar = InputStr.substring( InputLen - 1, InputLen);
if(SecondLast == " ")
RetValue = InputStr.substring(0,InputLen - 1) + LastChar.toUpperCase();
else
RetValue = InputStr;
}
if(InputBox.value != RetValue)
InputBox.value = RetValue;
}
Like (6)
Dislike (1)
Keywords for this article:
javascript || Upper case first letters
Advertisement by Google
Comment:
Code Language:
Code:
Here you can paste a code example. It will then be processed by SyntaxHighlighter and formatted for easier readability.
Please remember to select the correct Code Language in the select above so the SyntaxHighlighter can highlight the code properly.
Code:
Please enter the code you see above
What is 6 + 1 =