I have several field values that are in all caps and I want a function to change them to proper case structure. I found this:
function toTitleCase(str)
{
return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
}
but am not really sure what I need to change to get it to work, or if it is even workable. I've messed with this code as well:
function changeCase() {
var attribute = Xrm.Page.getAttribute("pps_lastname");
if (attribute != null)
var str = attribute.getValue();
var pieces = str.split(" ");
for (var i = 0; i < pieces.length; i++) {
var j = pieces[i].charAt(0).toUpperCase();
var i =
pieces[i] = j + pieces[i].substr(1);
}
Xrm.Page.getAttribute("pps_lastname").setValue(pieces.join(' '));
}
But it only capitalizes the first letter, so if it's all caps, it's really of no help. As you might guess from the above, the field I'm trying to change is "pps_lastname".
*This post is locked for comments
I have the same question (0)