Capitalize the sentence in Javascript!

JavaScriptCapitalize the sentence in Javascript!

<script type="text/javascript" language="javascript">// <![CDATA[
String.prototype.capitalize = function(){
   return this.replace( /(^|s)([a-z])/g , function(m,p1,p2){ return p1+p2.toUpperCase(); } );

function capWords() {
var inputString = document.form1.instring; // The input text field
var outputString = document.form1.outstring; // The output text field
outputString.value = inputString.value.capitalize();
// ]]></script>
Like to share it

No comments

Leave a Reply

Your email address will not be published. Required fields are marked *