jQuery datepicker for date of birth

Just configured a JQuery datepicker for taking date of birth input. It will show you 100 years to current date. You can’t select date beyond the yesterday date (present date is excluded). You can configure it more according to your needs. But if you just want a simple datepicker, it will work for you.

$(function() {
$( "#datepicker" ).datepicker({
dateFormat : 'mm/dd/yy',
changeMonth : true,
changeYear : true,
yearRange: '-100y:c+nn',
maxDate: '-1d'
});
});

See demo.

You can apply stylesheet of JQuery, on demo you will see calendar with no styles.

You May Also Like

9 Comments

  1. Why is the year range using the letters “y” and “nn”, I don’t thinks these are valid options following http://api.jqueryui.com/datepicker/#option-yearRange.

    I think it should read:
    … yearRange: ‘-100:c’ …
    to show the last 100 years.

    c = current year
    nnnn = placeholder for absolute year
    +nn or -nn = relative to today’s year
    c+nn or c-nn = relative to currently selected year

  2. Hey I need a little help, I have a page with multiple forms inside multiple tables which is hidden and shown using a drop-down list. So i have this date of birth option in all the 4 forms but the this datepicker is working in only 1st form, would you help me plz I have no xp in javascript

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.