Code:
<script>
String.prototype.capitalize = function() {
return this.charAt(0).toUpperCase() + this.substring(1,this.length).toLowerCase();
}
</script>
Usage:
Code:
var str = "martin_narg";
var string1 = str.capitalize();
// output is Martin_narg
// or
var string2 = ("martin_narg").capitalize();
// output = Martin_narg
This is an extension to the string object, so you can use it with any JavaScript string without repeating the code.
Hope this helps
m_n