Click here to Skip to main content
15,898,036 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am having two date controls where I need to validate the from date and to date

HTML
<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:

JavaScript
$("#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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900