Microsoft Dynamics CRM : How to customize a form using Javascript

One can customize a Microsoft CRM form using javascript with lots of ease.

Navigate to Go To ->Settings ->Customization
Select Customization Entities
Double Click on the entity that is needed for customization.
Click on Forms and Views and then double click on Form
Select Form Properties from Common Task panel.
It will open up the Form Properties dialog box with OnLoad and OnSave events.
Select any event and click on edit.

It will open up the event detail properties dialog box where one can enter the java script for customization. The code will be called when the event is triggered.

Following are few examples of customizing the Account form at Page Load
Change the Fore color of Label:

// it will change the Account Number Label to green bold
crmForm.all.accountnumber_c.innerHTML = "" + crmForm.all.accountnumber_c.innerText + "";

Change the background color of the form

document.all.tab0.style.backgroundColor = 'white';//General tab
document.all.tab1.style.backgroundColor = 'white';//Details tab
document.all.tab2.style.backgroundColor = 'white';//Administration tab
document.all.tab3.style.backgroundColor = 'white'; //Notes tab

 
Disable a form

document.body.disabled = true;

 
Hide an entire row

var accountname = crmForm.all.name;
while ((accountname.parentNode != null) && (accountname.tagName.toLowerCase() != "tr"))
{
   accountname = accountname.parentNode;
}
if (accountname.tagName.toLowerCase () == "tr")
{
   accountname.style.display = "none";
}

Retrieving the text of a lookup control

var list = crmForm.all..DataValue;
if (list [0] != null)
{
    var theSelectedText = list [0].name;
 }
150 150 Burnignorance | Where Minds Meet And Sparks Fly!