SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jul 2008
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    date of birth validation using java script

    hi all,
    can u please help me to validate date of birth using javascript.the date entered by the user should be greater than 17 yrs .help me with the code.


    Thanks&Regrds
    Srinivas

  2. #2
    SitePoint Enthusiast
    Join Date
    Dec 2007
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Srinivas,

    You may want to take a look at TMT validator by massimocorner.com. It is a javascript validator with well explained notes on the website.

    You might be able to find something a little more current. I use this though.

    Good luck! I hope you get it working. I know what is like to get stuck on a piece of code.

    Thanks,

    Staniel

  3. #3
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Here's one way to calculate their age.

    Code javascript:
    var form = document.getElementById('myForm');
    var dob = new Date(form.dob.value);
    var age = (new Date() - dob) / 1000 / 60 / 60 / 24 / 365;
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

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