Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 14th, 2006, 01:29 PM
Registered User
Join Date: Oct 2006
Location: Delhi, Delhi, India.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to ramesh055 Send a message via MSN to ramesh055 Send a message via Yahoo to ramesh055
Default Date Validation


I have a problem with datatime.
I drag 3 DropDownList in some aspx page and add items as month, days and year in the respective DropDownList.
Now i want to add numbers in days_DDL according to the no. of days the particular month have.eg- when user select February from month DropDownList then month_DDL should display only upto 28 days so that user cannot enter INVALID date as 30 Feb 2000 or something like that.
So i want valid date from user in the above prescribed manner.

can i write javascript for that so when user select the page does not go back to the server and take the immediate effect without flashback.

so please help to solve the problem..... and if possible with some code also.....

  #2 (permalink)  
Old November 15th, 2006, 11:09 AM
Friend of Wrox
Points: 1,935, Level: 17
Points: 1,935, Level: 17 Points: 1,935, Level: 17 Points: 1,935, Level: 17
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Aug 2004
Location: United Kingdom
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post


You can simply copy and paste the code below in notepad, save it as htm to see the result, but remember, I have not written the code here to validate leap year, that's the task for you.


            function FillDays(ID)
                    case "1":AddDays("31"); break;case "2":AddDays("28");break;case "3":AddDays("31");break;
                    case "4":AddDays("30");break;case "5":AddDays("31");break;case "6":AddDays("30");break;
                    case "7":AddDays("31");break;case "8":AddDays("31");break;case "9":AddDays("30");break;
                    case "10":AddDays("31");break;case "11":AddDays("30");break;case "12":AddDays("31");break;

            function AddDays(Total)

                //Add items
                for (var j = 1; j <= Total; j ++)
                    //Set text and value fields of dropdown
                    var optn = document.createElement("OPTION");
                    optn.text = j;
                    optn.value = j;

                    //Add items
                    document.getElementById("lstDays").options.add(opt n);

id=lstMonth onchange=FillDays(this.value)> <OPTION value=0
  selected>Select</OPTION> <OPTION value=1>Jan</OPTION> <OPTION
  value=2>Feb</OPTION> <OPTION value=3>Mar</OPTION> <OPTION value=4>Apr</OPTION>
  <OPTION value=5>May</OPTION> <OPTION value=6>Jun</OPTION> <OPTION
  value=7>Jul</OPTION> <OPTION value=8>Aug</OPTION> <OPTION value=9>Sep</OPTION>
  <OPTION value=10>Oct</OPTION> <OPTION value=11>Nov</OPTION> <OPTION
  value=12>Dec</OPTION></SELECT> <SELECT id=lstDays></SELECT>


Fortune favours the brave, so don't regret on missed oppurtunities.

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Date Validation aftabn10 PHP How-To 0 January 29th, 2007 10:35 AM
Date validation vacak Struts 0 November 21st, 2006 12:11 PM
date validation (again) crmpicco Javascript How-To 14 March 29th, 2006 06:58 PM
Date Validation surendran Javascript How-To 3 February 25th, 2005 07:40 AM
Date validation Raul Javascript 4 February 25th, 2004 04:04 PM

All times are GMT -4. The time now is 10:29 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.