-1

I have a form in which there are 2 jQuery datepickers, one for start date and a second one for end date. I want to add date range validation on them so client cannot select today's date and also future dates.

@{Html.BeginForm("ExportToExcel", "marketing", FormMethod.Get);}
<input type="hidden" value="@ViewBag.StartDate" name ="EXsd" />
<input type="hidden" value="@ViewBag.EndDate" name = "EXst" />
@{Html.EndForm();}

Can anyone please tell me how to write the JavaScript function to add date validation?

Simon Adcock
  • 3,554
  • 3
  • 25
  • 41
rao
  • 223
  • 2
  • 7
  • 17
  • are you using `jquery UI` datepickers ? if so, you should check out their example for date ranges, in which they restrict the selectable values of one datepicker based on current selection of the other datepicker in realtime. http://jqueryui.com/datepicker/#date-range – Dennis Mar 26 '13 at 08:25

1 Answers1

2

http://jqueryui.com/datepicker/#min-max

Restrict the range of selectable dates with the minDate and maxDate options. Set the beginning and end dates as actual dates (new Date(2009, 1 - 1, 26)), as a numeric offset from today (-20), or as a string of periods and units ('+1M +10D'). For the last, use 'D' for days, 'W' for weeks, 'M' for months, or 'Y' for years.

Natrium
  • 30,772
  • 17
  • 59
  • 73