0

I want to restrict the user to enter date of birth as today's date. Currently i am using the range from 1900 until current year. How to make the range from 1900 to a day before today e.g Today the date is 20/03/2014. The user should be able to enter date of birth from 1900 to 19/03/2014.

This is the script i am currently using

setDatePicker($("#date_of_birth_str"),"dd/mm/yy");
var currYear = '<fmt:formatDate  value="${now}" pattern="yyyy"/>';
$("#date_of_birth_str").datepicker("option","yearRange", "1900:"+currYear);`
Programmer
  • 39
  • 2
  • 10
  • 1
    This question has already been answered here: – Femi Mar 20 '14 at 02:39
  • Doesn't help i checked already. if instead of currYear i have currDate will that help. how do we get the current date here – Programmer Mar 20 '14 at 02:59
  • I'm sorry, what about here: ? – Femi Mar 20 '14 at 03:09
  • setting yearrange will not stop it on particular date -- u have to set min/max date ..u have to try something like this - http://www.jquerybyexample.net/2013/04/restrict-start-date-range-in-jquery-datepicker.html – Neha Mar 20 '14 at 03:43
  • i tried using this but it doesn't work `$("#date_of_birth_str").datepicker({ minDate: "01/01/01", maxDate: new Date() });` – Programmer Mar 20 '14 at 03:48
  • not works means u can select dates more than today date ? – Neha Mar 20 '14 at 03:56
  • yes.. exactly. i can choose dates more than today and the date range is coming from 2004 until 2024.. i want it to be from 01/01/1901 to one day before todays date – Programmer Mar 20 '14 at 03:57
  • Well i tried in this demo its works .. http://jsfiddle.net/dxbtp/97/ – Neha Mar 20 '14 at 04:09

0 Answers0