I have looked through a lot of the other threads on here with this question. I am having issues capitalizing the first letter of an input.
I cannot seem to get the substr()
function to work properly. It always returns the whole string with each word capitalized instead.
function crmForm_lastname_onblur(sourceField, sourceRowId) {
var x=document.getElementById("crmForm_lastname");
x.value=x.value.toLowerCase().replace(/\b[a-z]/g, function(letter) {
return letter.substr(0,1).toUpperCase()+letter.substr(1);
});
console.log(x.value);
}
Any help would be appreciated. I am no means a Javascript expert but I can understand what the code is doing in certain areas. Thank you.