0
 <td>
     <input id="dt_dec_date" data-bind="datepicker: vm.afi.Details.DecisionDate" />
 </td>

 DecisionDate: ko.observable(),

I need to ensure that the date is not more than today, I have tried using max but cant get it to work, any ideas.

Sorry if this is really simple but I ma new to knockout. I have this value coming from a server but the user is allowed to change it but can't go beyond todays date.

shadow
  • 21,823
  • 4
  • 63
  • 77
Simon
  • 205
  • 1
  • 3
  • 15

1 Answers1

1

Heavily inspired by this answer. Suppose, that you're using datepicker binding from that mentioned answer, then you just need to use the following markup:

<input id="dt_dec_date" data-bind="datepicker: decisionDate, datepickerOptions: { maxDate: new Date() }" />

And view model is:

var viewModel = {
    ...
    decisionDate: ko.observable(new Date("08/15/2014")),
    ...
};

See the demo.

Community
  • 1
  • 1
Ilya Luzyanin
  • 7,910
  • 4
  • 29
  • 49