Question

It sets the minDate as I mentioned.. but I want to display the default mindate 1970-01-26 in jquery datepicker. here I have coded like this, but it didnt worked. Can anyone help me please..

$(function ()
{
  var oldMethod = $.datepicker._generateMonthYearHeader;
  $.datepicker._generateMonthYearHeader = function()
  {
   var html = $("<div />").html(oldMethod.apply(this,arguments));
   var monthselect = html.find(".ui-datepicker-month");
   monthselect.insertAfter(monthselect.next());
   return html.html();
  }
  $('input.datepicker_DOB').datepicker(
  {
   dateFormat: 'yy-mm-dd',
   changeMonth: true,
   changeYear: true,
   minDate: '1970-01-26'
  });
});

and my html code is:

<input type="text" name="dob"  class="datepicker_DOB" >
Was it helpful?

Solution

Use setDate.

var defaultDateInput = new Date(1970, 01, 26);
$("input.datepicker_DOB").datepicker('setDate', defaultDateInput);

OR

var defaultDateInput = new Date(1970, 01, 26);
$("input.datepicker_DOB").val(defaultDateInput);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top