Forums

Forums / Developing Portals / Set the mindate of a CRM Date/Time to today

Set the mindate of a CRM Date/Time to today

Thread is closed for posting
4 posts, 2 answered
  1. j.mondy
    j.mondy avatar
    12 posts
    Registered:
    09 Oct 2015
    05 Jan 2016
    Link to this post
    I'm working on a CRM Date/Time widget that requires future dates only; this data field does not allow selecting dates before today. How can I enforce this specification on the client-side?
  2. Clinton Bale
    Clinton Bale avatar
    126 posts
    Registered:
    21 Feb 2014
    Answered
    11 Jan 2016 in reply to j.mondy
    Link to this post
    Hello,

    The only way to do this currently is through custom JavaScript, here is an example:

    var today = new Date();
    today.setDate(d.getDate()-1);
    findControl("CrmDateTimeField_C004").get_dateTimePicker().set_minDate(today);
    

    Regards,
    Clinton
  3. j.mondy
    j.mondy avatar
    12 posts
    Registered:
    09 Oct 2015
    13 Jan 2016 in reply to Clinton Bale
    Link to this post
    Very nice! This gets the desired functionality, but there is one small issue. The date before today is available as an option to be selected by the datepicker control. If the user selects this value, it fails validation, which is the desired validation, but how would I be able to make yesterday un-selectable?

  4. Clinton Bale
    Clinton Bale avatar
    126 posts
    Registered:
    21 Feb 2014
    Answered
    19 Jan 2016 in reply to j.mondy
    Link to this post
    Hello,

    To make yesterday unselectable just remove the "-1" inside of the setDate function call.
4 posts, 2 answered