datetime validation dd:mm:yyyy:hh:mm:ss format urgent

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • smitanaik
    New Member
    • Oct 2007
    • 26

    datetime validation dd:mm:yyyy:hh:mm:ss format urgent

    hi i want to do validation of datetime in javascripti.e is i want it in this format dd:mm:yyyy:hh:m m:ss

    plz heklp me out its urgent
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

    #2
    Originally posted by smitanaik
    hi i want to do validation of datetime in javascripti.e is i want it in this format dd:mm:yyyy:hh:m m:ss

    plz heklp me out its urgent
    [CODE=javascript]if (!input.match(/^[0-3][0-9]\:[0-1][0-9]\:[0-2][0-9][0-9][0-9]\:[0-2][0-9]\:[0-6][0-9]\:[0-6][0-9]$/)) {
    alert ('Invalid date');
    return false;
    }[/CODE]
    After this, split the string and validate each field.

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      If you're going to do that, you might as well accept any number- also makes the regexp smaller.

      Comment

      Working...