Hey Below is the Code To Set a Attribute / field on form Read only (Lock) using JavaScript in MS CRM .

// Get Control of entity
// Now set the property to lock the field

Note : Xrm.Page.ui.controls.get("new_companyreference"); by this we get full UI controls of the attribute / field by which we can set or get any ui property of that field .

SOURCE : JUST2CODE.IN Subscribe to our YouTube channel : https://www.youtube.com/user/TheRussell2012