Greetings, I want to use every word in the script, for this I came up with this method:
function wordToUpper(val) {
newVal = '';
val = val.toLowerCase().split(' ');
for(var c=0; c < val.length; c++) {
newVal += val[c].substring(0,1).toUpperCase() + val[c].substring(1,val[c].length) + ' ';
}
return newVal;
}
Now it works for regular words, starting with and emtpy char "".
However, I also want to make sure that it does not work for such lines:
wordToUpper('hello my name is Hellnar.it doesnt work.')→ Hello My Name Is Hellnar.it Doesnt Work.“this” was supposed to be capital.
wordToUpper('hello my name is (hellnar).')→ Hello My Name Is (hellnar)."Hellnar" was to become capital.
Hi
Note: Please do not classify css classic text-transform: capitalize;, as this data will be used to publish the form.
source
share