Opened 12 years ago

Closed 12 years ago

#6917 closed bug (wontfix)

Datepicker min/maxDate don't prevent typing in dates outside this range

Reported by: WetCoast Owned by:
Priority: minor Milestone: 1.9.0
Component: ui.datepicker Version: 1.8.9
Keywords: Cc:
Blocked by: Blocking:


While setting minDate and maxDate restricts selecting a date from the datepicker popup calendar, the user can still type a date outside this range into the text field and then tab to the next field, leaving the date outside the range in the text field.

Here is some reduced code demonstrating this. The date should be restricted to between 1/1/1990 and 12/31/1999, but when the calendar pops up, you can still type 1/1/1700 into the field and tab to the next, leaving the date in place even though it is outside the expected range.

<!DOCTYPE html>
   <meta charset="UTF-8">
   <link type="text/css" rel="stylesheet" href="" />
   <script type="text/javascript" src=""></script>
   <script type="text/javascript" src=""></script>
   <script type="text/javascript">
$(document).ready(function() {
      changeMonth: true,
      changeYear: true,
      dateFormat: 'mm/dd/yy',
      minDate: new Date(1990, 0, 1),
      maxDate: new Date(1999, 11, 31)
         <label for="mydate">Date</label>
         <input type="text" name="mydate" id="mydate" maxlength="12" class="date">
         <label for="next">Next</label>
         <input type="text" name="next" id="next" maxlength="12">

Change History (1)

comment:1 Changed 12 years ago by Scott González

Resolution: wontfix
Status: newclosed

The datepicker widget is only designed to restrict dates within the calendar. If you want to prevent users from manually typing in an invalid date, you should use the validation plugin or make the text field readonly.

Note: See TracTickets for help on using tickets.