Disable date and Item in Form

Hi, I have a form with an field type="Date" (Name=expiring_date) and another field type="Item" (Name=item_code). I would disable during the OnFormPolulated event if the state is different from released. I tried: document.getElementsByName("expiring_date")[0].disabled=true; or getFieldByName("expiring_date").disabled = true; But doesn't work. Any suggestion? Thanks