I am using ASP.NET MVC with WEB API.
I need to provide user to enter his date of birth, the input should be 3 drop downs
- Select Day
- Select Month and
- Select Year
I am able to populate the dropdowns using the following code...
@Html.DropDownList("month", Enumerable.Range(1, 12).Select(i => new SelectListItem { Value = i.ToString(), Text = System.Globalization.CultureInfo.InvariantCulture.DateTimeFormat.GetMonthName(i)}), "-- Month --")
@Html.DropDownList("day", Enumerable.Range(1, 31).Select(i => new SelectListItem { Value = i.ToString(), Text = i.ToString()}), "-- Day --")
@Html.DropDownList("year", Enumerable.Range(1920, DateTime.Now.Year).Select(i => new SelectListItem { Value = i.ToString(), Text = i.ToString()}), "-- Year --")
However I still will have to write custom js or C# code to make sure for example : February doesn't have more than 28 days for a particular year etc etc..
Is there any other method which you can suggest please... Please share your thoughts on this.
EDIT : I am not using Jquery Date Picker, as in my requirement I have to have 3 drop downs for day, month and year, every where else in the app for the rest of date selection I have used Jquery DatePicker.