3 drop downs must be within date range

B

bluelaser

Hi there, i'm developing an asp.net page which contains 3 drop dow
boxes each for day, month and year. The problem i have is i need t
ensure that the dates the user selects must be within a certain dat
range. For eg, it has to be between 1 Dec 2005 to 1 May 2006. It seem
that the validation controls provided isn't sufficient to do the jo
for me. Can anyone give me a solution to this problem? BTW, i'm usin
C#


-
bluelase
 
P

Peter Rilling

Well, it looks as if December, January, February, March, and April have no
constraints on the dates.

When the user changes the dropdown item, do a postback and update the
available items in the other lists. For example, When if the user selects
January, then update the list of dates to reflect that month meaning the
items will range from 1 through 31.

This problem really does not require validation but rather constraints on
what the person can choose to begin with.

--> The month list only needs to contain a static list of items, Dec
through May.
--> The day list will change based on what month is selected.
--> The user should never really need to change the year since your range
is only for six months, it is assumed that if they select Feb, then it means
2006.
 
G

Guest

I like Peter's recommended approach of narrowing down the selections. I
would add one more approach for the case where a postback can incur heavy
cost.

One might compose the date from the 3 dropdownlists using Javascript (on the
client browser) and write it in a read-only (or hidden) textbox which is
validated by 2 asp:CompareValidators (against the upper and lower limits of
your date range). Here is a quick snippet of code:
http://www.societopia.net/samples/javascript_trivia.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top