CRM 2011 Javascript - Form Disabled

function onLoad()
{
    disableFormFields(true);
}

function disableFormFields(onOff)
{
    Xrm.Page.ui.controls.forEach(function (control, index)
    {
        if (doesControlHaveAttribute(control))
        {
            control.setDisabled(onOff);
        }
    });
}

function doesControlHaveAttribute(control)
{
    var controlType = control.getControlType();
    return controlType != "iframe" && controlType != "webresource" && controlType != "subgrid";
}