Date field not get disabled

Hi,

I am trying to disable date field when item is locked, I did something like this:

Method is hooked on form event "OnFormpopulated"

var isItemLocked = thisItem.isLocked();

var transfer_date = getFieldByName("transfer_date");

if(isItemLocked)
{

       transfer_date.getElementsByTagName("input")[0].disabled = true;
       transfer_date.getElementsByTagName("input")[1].disabled = true;
       transfer_date.getElementsByTagName("input")[1].src = "../images/calendar-disabled.svg";

}

Reference from : gist.github.com/.../bb83b790e66d1977eeb09b1769c5a61c

so, when I locked item then date field won't get disabled, and if I unlock it and again lock it then it works fine i.e date field gets disabled.

I debug the code but the behavior is same when Item is locked first time and second time.

I tried this on IE, Chrome and Firefox but the got same results.

Regards,

Maddy.