Kipp, James wrote: > What is the best way to validate form data. I have a form which the user > enters dates like '08/01/2002'. What is the best way to make sure this > format is entered. Should i use javascript here or regex?
i had some free time, so i decided to finish up some thoughts i have regarding validating form data. i've developed a simple module to perform basic validation and shown how to implement it. it's all available here: http://www.peacecomputers.com/form_checker/ please send any errata or general comments directly to me, not the list. many thanks to Eric Moore ([EMAIL PROTECTED]) for his help and patience during development. please note that this module doesn't really answer the question posed by the original poster, namely 'how do i validate a date?' imho, i'd do that like this (for slash-delimited dates only): use strict; use Date::Calc qw(check_date); my @date = qw( 08/02/2002 7/3/2003 13/3/2006 09/33/2002 al/df/ioji 09/14/66 ); for my $date (@date) { my ($month, $day, $year) = split "/", $date; if (check_date($year,$month,$day)) { print "$date is kosher\n"; } else { print "$date is uncool\n"; } } OUTPUT 08/02/2002 is kosher 7/3/2003 is kosher 13/3/2006 is uncool 09/33/2002 is uncool Argument "ioji" isn't numeric in subroutine entry at try1.pl line 17. Argument "al" isn't numeric in subroutine entry at try1.pl line 17. Argument "df" isn't numeric in subroutine entry at try1.pl line 17. al/df/ioji is uncool 09/14/66 is kosher -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]