views:

66

answers:

2

Hi,

I am showing the birthday option and have used the jquery ui date picker. The problem is that I want show past dates for example starting from 1950 till 2000 but I don't know how to do that, i tried this but it did not work:

$('#dob').datepicker({
    showOn: 'button',
    buttonImage: 'images/calendar.gif',
    buttonImageOnly: true,
    dateFormat: 'mm/dd/yy',
    changeYear: true,
    minDate: '-20Y',
    maxDate: '+1M +10D'
    });

Ref:

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

Update:

Here is what, I am doing, you could fix that by updating the code there:

http://jsbin.com/uyake

Thanks

+1  A: 

Use date object as a value in your minDate and maxDate options, ex:

{ 
  minDate: new Date(1950, 0, 1),
  maxDate: new Date(2000, 11, 31) 
}

This is done according to: http://jqueryui.com/demos/datepicker/#option-minDate

rochal
it shows starting from 2000 and ahead :(
Web Logic
Are you sure you didn't mix up minDate and maxDate? Also - make sure every property but the last one ends with coma. Also make sure you didn't put two "minDate" there.
rochal
@rochal: Yes iam sure i did it fine but still no luck
Web Logic
+4  A: 
$('#dob').datepicker({
    showOn: 'button',
    buttonImage: 'images/calendar.gif',
    buttonImageOnly: true,
    dateFormat: 'mm/dd/yy',
    changeYear: true,
    minDate: new Date(1950, 0, 1) ,
    maxDate: new Date(2000, 11, 31),
    defaultDate: new Date(1950, 0, 1),
    yearRange: '1950:2000'
    });

Working Demo is here:

Kai
thanks but this shows starting from 1950 to 1960 not 2000
Web Logic
Edited..! plz check again..
Kai