#*** NON-TESTED CODE *** # RUN AT YOUR OWN RISK :) use Time::Local;
if ($in{'timestartPM'}) { # make a radio button set where either AM or PM is selected $in{'timestarthour'}+=12; } if ($in{'timeendPM'}) { $in{'timeendhour'}+=12; } #you'll have to do some error-checking for some of the other variables I've added below. $timestart = timelocal(0,$in{'timestartminute'},$in{'timestarthour'}, $in{'timestartdayofmonth'},$in{'timestartmonth'},$in{'timestartyear'}); $timeend = timelocal((0,$in{'timeendminute'},$in{'timeendhour'}, $in{'timeenddayofmonth'},$in{'timeendmonth'},$in{'timeendyear'}); unless ($timestart < $timeend) { # can't have a zero-minute meeting # display error here } # I'm sure you've got the rest. --- .ted -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, May 29, 2003 6:31 PM To: [EMAIL PROTECTED] Subject: newbie question - re: form validation ?JUNK MAIL? Hi. I'm a newbie: both to this news group and to land of Perl/cgi :o) .... I'd appreciate getting some help with a form validation script! I'm working on a conference room reservation form. The html form has fields for name, title of meeting, day/month/year, start time and end time. My current problem is the date validation - I need it to not only check for whether there has not been a selection made, but also whether the start time is => end time and end time <= start time, returning errors in any of these cases. My form fields for time start and time end are selection boxes, both with the am/pm designation included with the numeric time - i.e.6:00 am through 6:00pm (in half hour increments). The problem is when the start time is =< 12:30 pm and the end time selected is =>1pm -- if this selection is made, the .cgi sees the end time as less than the start time and returns an error. If I change the selection box listing to military time, I can get the script to work, but I don't like using that format (and I think most users would agree). What code can I use to make the .cgi recognize the difference in am/pm using the standard time format? Thanks, Marjie -------- Here's is the portion of my .cgi showing the code for the time field(s) validation: elsif ($in{'timestart'} eq "Select one:") { print "<html><body bgcolor=red><table width=50% bgcolor=white>\n"; print "<tr><td><b>Oops! You forget to fill in the `Time Start' field.\n"; print "<p><b>Use the back button to return to the form\n"; print "<b>and complete the info needed. Thank you!</b></td></tr></table></body></html>"; } elsif ($in{'timeend'} eq "Select one:") { print "<html><body bgcolor=red><table width=50% bgcolor=white>\n"; print "<tr><td><b>Oops! You forget to fill in the `Time End' field.\n"; print "<p><b>Use the back button to return to the form\n"; # print "<b>and complete the info needed. Thank you!</b></td></tr></table></body></html>"; } if ($in{'timestart'} >= $in{'timeend'} ) { print "<html><body bgcolor=red><table width=50% bgcolor=white>\n"; print "<tr><td><center><b>Oops!</center>\n"; print "<b>Your `<font color=red>Time Start and Time End' *are in conflict*</font><br> \n"; print "<b>Please use the back button to return to the\n"; print "<b>reservation form, and reselect your \n"; print "<b>start or end time.<br>\n"; print "<center><b>Thank you!</b></center></td></tr></table></body></html>"; } else { -------------- FYI-After this portion of the code, the .cgi is to open the .txt database and check for any duplicate entry. If none found, it writes; if duplicate date found, it should return another error. But haven't gotten that far yet! Thanks in advance for help correcting/completing this code! Marjie --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.486 / Virus Database: 284 - Release Date: 5/29/2003 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]