We have a field called need by date, So how to prevent user to select past dates from current date . or How to disable past dates in calendar from current date.

  • Do you need to prevent user from adding dates from past days in list's new/edit item form? – Dikesh Gandhi Jan 15 at 4:22

You can create a validation rule on that date column setting, but this validation rule will work on new item add but when you edit the item, it will not allow us to save because of the validation rule, in which we would have mentioned your date field value should be greater than today. So better option is to have JavaScript code on date picker control and restrict the past dates. Use the below code,

Add the below code in your new/edit form

<script type="text/javascript">
    var getSPDayDiff = function (date) {
        return Math.round(Math.abs((new Date(1601, 0, 1).getTime() - date.getTime()) / (24 * 60 * 60 * 1000)));
    $(function () {

        var minDay = getSPDayDiff(new Date());
        //DT is your datetime field 
        var datePicker = $("img[id^='DT']").parent();
        var onclickStr = datePicker.attr("onclick");
        onclickStr = onclickStr.replace("minjday=109207", "minjday=" + minDay);
        datePicker.attr("onclick", onclickStr);

You can use column validation formula from list settings on your date time field, where you can restrict user from adding dates greater than or equal to tomorrow using below formula:


Here, StartDate is column name. You will have to add this formula in column settings. Please below screenshot for the same: enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.