341129 visitors has seen the Tim-Carter.com site. Thanks!
364 visitors has seen the Tim-Carter.com site today.
 
 
Search :  
 
>>> Programming >> Javascript > Upcase First Letters (This page has been seen 598 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:
		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
 
Dislike


Keywords for this article:
javascript || Upper case first letters

Post comment

Name:


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 + 2 =

Submit Comment


No one has commented on this page yet. You could be the first.


Advertisement by Google