Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Hem
    Hem is offline
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Leap year validation-urgent

    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
    Last edited by Hem; 06-08-2007 at 07:53 AM.

  • #2
    Hem
    Hem is offline
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Leap Year Validation-urgent

    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

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,627
    Thanks
    0
    Thanked 646 Times in 636 Posts
    If you have the year month and day in fields by those names then the following code will do it for you.

    Code:
    function daysInMonth(month,year) {
    var dd = new Date(year, month, 0);
    return dd.getDate();
    }
    if (day > daysInMonth(month,year)) alert('invalid day selected');
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #4
    $object->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Jun 2003
    Posts
    3,088
    Thanks
    2
    Thanked 23 Times in 23 Posts
    Here is a solution for you. Hope it helps.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    SNAP to it!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •