Thursday, August 20, 2015

Capitalize each word after forward slash in Java Script : Code snippet

Be The First To Comment
 function getFormattedText() {  
   var formattedString= capitalizedTextAfterBackslash("Red spruce / balsam fir/tamarack");    
   alert(formattedString);  
 };  
 function capitalizedTextAfterBackslash(str){  
    var temp= str.split("\/");       
    for(var i=0; i<temp.length; i++) {  
     temp[i] = temp[i].trim();  
     temp[i] = temp[i].substr(0,1).toUpperCase() + temp[i].substr(1,temp[i].length-1);  
    }  
    return temp.join(' / ');   
 }  
 

© 2011 GIS and Remote Sensing Tools, Tips and more .. ToS | Privacy Policy | Sitemap

About Me