in reply to Simple Date Validation

This is what I have so far
if ($dated =~ /^(?:[01]\d\/[0-3]\d\/(?:19|20)\d\d)?$/) { my ($sec,$min,$hour) = qw( 0 0 12 ); my ($mday, $mon, $year) = split /\//, $dated; $mon--; # because that's how unix/C treat the month value eval { my $dummy = timelocal($sec,$min,$hour,$mday,$mon,$year); }; if (my $err = $@) { $passfail = 0; $errmsg = 'Unable to use date format. Please use "MM/DD/YYYY" +or MM-DD-YYYY for the Date Delivered Field'; $errtitle = 'Validation Error'; $seconds = 7; } else { }; } else { #User entered an invaild date. $passfail = 0; $errmsg = 'Unable to use date format. Please use "MM/DD/YYYY" or M +M-DD-YYYY for the Date Delivered Field'; $errtitle = 'Validation Error'; $seconds = 7; } if ($dreceived =~ /^(?:[01]\d\/[0-3]\d\/(?:19|20)\d\d)?$/) { } else { #User entered an invaild date. $passfail = 0; $errmsg = 'Unable to use date format. Please use "MM/DD/YYYY" or M +M-DD-YYYY on the Date Received field'; $errtitle = 'Validation Error'; $seconds = 7; }

But its still validating dates like: 15/10/2007

Replies are listed 'Best First'.
Re^2: Simple Date Validation
by shmem (Chancellor) on May 13, 2007 at 08:27 UTC

    But its still validating dates like: 15/10/2007

    Of course, since you

    my ($mday, $mon, $year) = split /\//, $dated;

    which means you treat $dated as DD/MM/YYYY.

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}