Terribly sorry if this gets posted twice ...

On Tue, 24 Jul 2001, Mark Byerley wrote:
> Good Morning/Afternoon to all
> 
> I need some error checking (or rather field validation) within my script
> itself to ensure a date field coming across on a form is in the format of
> dd-mm-yyyy. I would rather not have to strip the field down to check the
> individual numbers and then put them back together again. Is there any
> "simple" type of error checking I can use in this instance? I appreciate the
> help.
> Thank you
> M~

How about pattern matching?

if ($date !~ m/\b(0[1-9]|[12][0-9]|3[01])-(0[1-9]|1[0-2])-\d{4}\b/) {
        reject ...
} else {
        accept ...
}

Note that the day and month matchings are robust within themselves
(i.e. no day "00" or month "19") but are not robust against each other
(i.e. "31-09-xxxx" would be accepted).  Also my year check is not
robust at all. :)

Daniel


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to