Click here to Skip to main content
14,424,458 members
Rate this:
Please Sign up or sign in to vote.
See more:
I am having two date controls where I need to validate the from date and to date

<div class="row">
    <div class="col-xs-12 col-sm-6 col-md-6">
      <div class="form-group">
         From Date
          @Html.TextBoxFor(m => m.FromDate, new { @class = "form-control", @tabindex = "2" })
          @Html.ValidationMessageFor(m => m.FromDate, "", new { @class = "label-danger" })
                    </div>
                </div>
 </div>

 <div class="row">
    <div class="col-xs-12 col-sm-6 col-md-6">
      <div class="form-group">
         To Date
          @Html.TextBoxFor(m => m.ToDate, new { @class = "form-control", @tabindex = "2" })
          @Html.ValidationMessageFor(m => m.ToDate, "", new { @class = "label-danger" })
                    </div>
                </div>
 </div>


I need to validate like to date should be greater than or equal to from date, or if user select from date I need to block all the dates which are less than to date

I tried the following code to disable the dates before from date, but it is not working

What I have tried:

$("#FromDate").on("change.dp", function (e) {
    $("#ToDate").datepicker("option", "minDate", e.date);
});
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100