I am trying to format a telephone number field in CRM 2011, but only if the field contains 10 digits. Some of the numbers have extensions, but I want to ignore those for now. I hacked existing code the best I could, but w/ my extremely limited knowledge of JS I will need some assistance. Any help is appreciated. Below is what I have so far..
var phone = Xrm.Page.data.entity.attributes.get("telephone1");
if(phone.length == 10)
{
phone.setValue( "(" + phone.substr(0, 3) + ") " + phone.substr(3, 3) + "-" + phone.substr(6, 4));
}