locked
Disable past and future dates in datetime picker RRS feed

  • Question

  • Hi,

    I have a very specific task on hand. I want to disable(grey out) all past dates and future dates except current date in MS CRM. Is there any way to achieve this?


    • Edited by rutuls Wednesday, May 25, 2016 10:33 AM
    Wednesday, May 25, 2016 10:32 AM

All replies

  • Hi,

    What you are asking for is probably an unsupported feature,

    Supported way to accomplish your requirement is to add a JavaScript function which would validate the date.

    var crmDate = Xrm.Page.getAttribute("new_datefield").getValue(); var today = new Date(); if(crmDate < today || crmDate > today){ alert("Invalid date");

        Xrm.Page.getAttribute("new_datefield").setValue(today);
    

    }

    Hope this helps,

    Regards,

    Darrel

    Please mark as helpful or mark as answer if the solution has helped you,


    Monday, May 30, 2016 5:01 AM
  • Hi Rutuls,

    Can you please explain further what you are hoping to achieve by disabling all past and future dates?

    It sounds like it would be easier to just default the Date field to the current date, and set it to be a Disabled field.

    Xrm.Page.getAttribute("<datefield>").setValue(new Date());

    ~ Nathan

    Wednesday, June 1, 2016 4:29 AM
  • You need to get all the attribute in form check the type of attribute if it is date type then disable  the attribute or set current date.

    If not satify plz contact reply me.


    ms crm

    Wednesday, June 1, 2016 6:20 AM