PDA

View Full Version : Need a Function to capitalize first letter



liffland
04-15-2005, 03:43 AM
I want to add to my library a function that will capitalize first letter and the remaining letters in lowercase.

jscheuer1
04-15-2005, 06:24 AM
<script type="text/javascript">
function stCap(strObj){
return(strObj.charAt(0).toUpperCase()+strObj.substr(1).toLowerCase());
}
document.write(stCap('loL, Get Me hoMe!'))
</script>You can use just the function by itself for whatever purpose you need/want it. Paste the above script into the body of a page to see it in action.