locked
Datetime field not disabling RRS feed

  • Question

  • Hello,

    I have an issue with the datetime filetype.  I have a field on my form that is displaying the date and the time.  When I go to disable the field, the date portion looks like it is still available to enter as well as the picklist.  How can I make sure that the entire field is disabled?

    Here is my code:

                crmForm.all.new_oev_1strescheduledate.disabled= true;

    Thanks in advance!!

    Eddi Rae

    Wednesday, September 1, 2010 1:12 PM

Answers

  • Hi

    Disabling dates in CRM works differently i.e. you need to disable the img tag associated with the control as well as the textbox, 

    please use this code to do the same

    USAGE:

    Example : - SetReadOnlyCrmDateField('dateofbirth', true)


    function SetReadOnlyCrmDateField(elementName, isReadOnly) {
        if (elementName != null) {
            var elem = document.getElementById(elementName + "img");
            if ((typeof (elem != "undefined")) && (elem != null)) {
                if (isReadOnly) {
                    elem.disabled = true;

                    // Also disable date text field
                    var node = elem.parentNode.previousSibling.firstChild;
                    node.disabled = true;
                    elem.src = '/_imgs/btn_dis_cal.gif';
                    node.className = "ro";

                }
                else {
                    elem.disabled = false;
                    var node = elem.parentNode.previousSibling.firstChild;
                    node.disabled = false;
                    elem.src = '/_imgs/btn_on_cal.gif';
                    node.className = "";
                }
            }
        }
    }


    Hope this helps. Amar
    • Proposed as answer by Amarsen Vangoor Wednesday, September 1, 2010 1:59 PM
    • Marked as answer by EddiRaeM Wednesday, September 1, 2010 3:08 PM
    • Unmarked as answer by EddiRaeM Wednesday, September 1, 2010 3:46 PM
    • Marked as answer by EddiRaeM Wednesday, September 1, 2010 3:53 PM
    Wednesday, September 1, 2010 1:56 PM

All replies

  • Hello,

    Are you sure you publish your customization?


    Akvelon Inc - Microsoft CRM customization services
    Wednesday, September 1, 2010 1:24 PM
  • yes ... the form is published. 

    Wednesday, September 1, 2010 1:30 PM
  • Could you remove this attribute from entity form at all or you need just to disable it?

    Akvelon Inc - Microsoft CRM customization services
    Wednesday, September 1, 2010 1:34 PM
  • It is available only when another attribute is a certain value.  This field needs to be there.  I guess I could make it invisible until then.  That may work.
    Wednesday, September 1, 2010 1:36 PM
  • Hi

    Disabling dates in CRM works differently i.e. you need to disable the img tag associated with the control as well as the textbox, 

    please use this code to do the same

    USAGE:

    Example : - SetReadOnlyCrmDateField('dateofbirth', true)


    function SetReadOnlyCrmDateField(elementName, isReadOnly) {
        if (elementName != null) {
            var elem = document.getElementById(elementName + "img");
            if ((typeof (elem != "undefined")) && (elem != null)) {
                if (isReadOnly) {
                    elem.disabled = true;

                    // Also disable date text field
                    var node = elem.parentNode.previousSibling.firstChild;
                    node.disabled = true;
                    elem.src = '/_imgs/btn_dis_cal.gif';
                    node.className = "ro";

                }
                else {
                    elem.disabled = false;
                    var node = elem.parentNode.previousSibling.firstChild;
                    node.disabled = false;
                    elem.src = '/_imgs/btn_on_cal.gif';
                    node.className = "";
                }
            }
        }
    }


    Hope this helps. Amar
    • Proposed as answer by Amarsen Vangoor Wednesday, September 1, 2010 1:59 PM
    • Marked as answer by EddiRaeM Wednesday, September 1, 2010 3:08 PM
    • Unmarked as answer by EddiRaeM Wednesday, September 1, 2010 3:46 PM
    • Marked as answer by EddiRaeM Wednesday, September 1, 2010 3:53 PM
    Wednesday, September 1, 2010 1:56 PM
  • Hi Eddi,

    you just need to do this line as below..(notice : D is in uppercase)

    crmForm.all.new_oev_1strescheduledate.Disabled= true;

    this should fix the issue , hope this helps..


    MayankP My Blog My twitter
    Wednesday, September 1, 2010 2:22 PM
    Answerer
  • One question I do have ... I am checking the DataValue to see if there is something entered.  If someone enter the date, this disables the field so that the time cannot be entered.  What would I check to make sure that the field is still enabled until the time has been entered?

     

    Thanks

    Eddi Rae

    Wednesday, September 1, 2010 3:16 PM
  • It doesn't seem to disable the time portion.
    Wednesday, September 1, 2010 3:46 PM
  • Sorry Eddi,

    Could you please elaborate your question I'm not following it?

     


    Hope this helps. Amar
    Wednesday, September 1, 2010 3:53 PM
  • I have it working.  I still need to disable the field as well as run it against your code.  The time piece was not being disabled. 

    Thanks!!

    Wednesday, September 1, 2010 4:00 PM
  • The above code doesnot work with time fields let me have a look and get back to you. Oneway to work around it is to include the time fields as well in the above code. 

    Hope this helps. Amar
    Wednesday, September 1, 2010 4:12 PM