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.

Parents
  • Hi Maddy

    Did you tried using the time out option. Try tweaking around the time out value (here it is 200)  and increase or decrease depends on the performance of your environment.


    var isItemLocked = thisItem.isLocked();

    var transfer_date = getFieldByName("transfer_date");

    disableDateField = function() {
    if(isItemLocked)
    {
    transfer_date.getElementsByTagName("input")[0].setAttribute("disabled", "");
    transfer_date.getElementsByTagName("input")[1].setAttribute("disabled", "");
    transfer_date.getElementsByTagName("input")[1].src = "../images/calendar-disabled.svg";
    }};
    setTimeout(disableDateField, 200);

    It works well in my environment

    Thank You

    Gopi

Reply
  • Hi Maddy

    Did you tried using the time out option. Try tweaking around the time out value (here it is 200)  and increase or decrease depends on the performance of your environment.


    var isItemLocked = thisItem.isLocked();

    var transfer_date = getFieldByName("transfer_date");

    disableDateField = function() {
    if(isItemLocked)
    {
    transfer_date.getElementsByTagName("input")[0].setAttribute("disabled", "");
    transfer_date.getElementsByTagName("input")[1].setAttribute("disabled", "");
    transfer_date.getElementsByTagName("input")[1].src = "../images/calendar-disabled.svg";
    }};
    setTimeout(disableDateField, 200);

    It works well in my environment

    Thank You

    Gopi

Children