in reply to Re: Roll your own date validation
in thread Roll your own date validation

Am I sure the month will always be two digits? Yes, I'm 100% positive and from the snippet below, it'll also relieve your wonders on why I'm comparing to a number.

With all that beside us now, can someone help me setup the max day checker?

print <<"ALL"; Day: <SELECT NAME="day" SIZE="1"> <OPTION SELECTED> $editday <OPTION> 01 <OPTION> 02 <OPTION> 03 <OPTION> 04 <OPTION> 05 <OPTION> 06 <OPTION> 07 <OPTION> 08 <OPTION> 09 <OPTION> 10 <OPTION> 11 <OPTION> 12 <OPTION> 13 <OPTION> 14 <OPTION> 15 <OPTION> 16 <OPTION> 17 <OPTION> 18 <OPTION> 19 <OPTION> 20 <OPTION> 21 <OPTION> 22 <OPTION> 23 <OPTION> 24 <OPTION> 25 <OPTION> 26 <OPTION> 27 <OPTION> 28 <OPTION> 29 <OPTION> 30 <OPTION> 31 </SELECT> Month: <SELECT NAME="month" SIZE="1"> <OPTION SELECTED> $editmonth <OPTION> 01 <OPTION> 02 <OPTION> 03 <OPTION> 04 <OPTION> 05 <OPTION> 06 <OPTION> 07 <OPTION> 08 <OPTION> 09 <OPTION> 10 <OPTION> 11 <OPTION> 12 </select> Year: <SELECT NAME="year" SIZE="1"> <OPTION SELECTED> $edityear <OPTION>04 <OPTION> 05 <OPTION> 06 </select> </td></tr> <tr><td>Course:</td><td> <SELECT NAME="course" SIZE="1"> <OPTION SELECTED> $course <OPTION>GDP Mod 1 <OPTION>GDP Mod 2 <OPTION>GDP Mod 3 <OPTION>GDP Mod 4 <OPTION> <OPTION>HYG Mod 1 <OPTION>HYG Mod 2 <OPTION>HYG Mod 3 <OPTION> <OPTION>Carers Sp. Needs <OPTION>VDP <OPTION>CDP Sp Needs <OPTION> <OPTION>TBC <OPTION>Lecture Day <OPTION>Other </SELECT>

Replies are listed 'Best First'.
Re: (3) Roll your own date validation
by Corion (Patriarch) on Jan 09, 2004 at 12:33 UTC

    I would do the comparision numerically, because you are, in fact, comparing numbers.

    Are you really really sure, that your $month does match /^\d{2}$/ ? Because your OPTION fields seem to contain a space before the number, and I am not really sure whether browsers will strip that space.

    For me, your original code works without and problem and I am able without further problem to trigger any of the three conditions.

    So I can only recommend really closely checking your input (for example by using the mentioned CGI::Untaint::date, and/or Time::Local). And also revisit your date/time math, as the month you associate with the number 1 will always have 31 days, and not 29 days, even though you cut it off there.

    Personally, to make sure an entered date exists, I would use Time::Local, which throws an error for invalid day/month/year combinations.

    perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web