I am using ASP.NET MVC with WEB API.
I need to tell the user to enter his date of birth, the entrance should be 3 drops
- Choose day
- Choose month and
- Choose year
I can fill out the dropdown lists 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 have to write custom js or C # code to make sure, for example: February is not more than 28 days for a certain year, etc. etc.
Is there any other method that you can suggest, please ... Please share your thoughts on this.
EDIT : I do not use JQuery Date Picker, since by my requirement I should have 3 drop downs for day, month and year, somewhere else in the application for the rest of the date picker I used JQuery DatePicker.
source share