...

View Full Version : Leap Year Validation-urgent



Hem
06-08-2007, 07:47 AM
Hi all

Greetings

I have dropdown for month and work days(in a month),textbox for year(yyyy).

I need to validate, if user select febraury and select other than 28 ( for non leap year), and select other than 29 ( for leap year) user should get error message.

same validations should be done for other months also.I need in Javascript or C#(VS2005)

Plz help me--urgent

Thanks in advance

Hem
06-08-2007, 07:54 AM
Hi all

Greetings

I have dropdown for month and work days(in a month),textbox for year(yyyy).

I need to validate, if user select febraury and select other than 28 ( for non leap year), and select other than 29 ( for leap year) user should get error message.

same validations should be done for other months also.I need in Javascript or C#(VS2005)

Plz help me--urgent

felgall
06-08-2007, 09:02 AM
If you have the year month and day in fields by those names then the following code will do it for you.


function daysInMonth(month,year) {
var dd = new Date(year, month, 0);
return dd.getDate();
}
if (day > daysInMonth(month,year)) alert('invalid day selected');

vinyl-junkie
06-10-2007, 12:30 AM
Here (http://www.codeguru.com/vb/gen/vb_misc/date/comments.php/c2717/?thread=36248) is a solution for you. Hope it helps.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum