Shawn Hinchy wrote:
Quoting Jonathan Mangin <[EMAIL PROTECTED]>:
----- Original Message -----
From: "Jonathan Mangin" <[EMAIL PROTECTED]>
To: <beginners-cgi@perl.org>; <[EMAIL PROTECTED]>
Sent: Wednesday, May 02, 2007 9:51 AM
Subject: Re: Odd select box behaviour
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <beginners-cgi@perl.org>
Sent: Tuesday, May 01, 2007 8:21 PM
Subject: Odd select box behaviour
> This one has me stumped, and it shouldn't.
>
> I'm trying to validate data from a simple select box:
>
> <select size="1" name="country">
> <option selected value='United States'>United States</option>
> <option value='Canada'>Canada</option>
> </select>
>
> When I do:
>
> foreach my $Item (param())
> {
> my $input=param($Item);
> print "$Item --$input--<br>\n";
> }
>
> the data is printed out with the expected leading and trailing '--'.
>
> But when I try to validate the incoming data:
>
> my $Country=param('country');
> if ($Country ne 'Canada' || $Country ne 'United States')
> {
> $Status=1;
> $ErrMsg .= "$Mandatory{country} must be either Canada or United
> States.<br>";
> }
>
Shouldn't that be:
if ($Country ne 'Canada' && $Country ne 'United States') {
No, I guess not. Ignore me...
It looks to me like you were right, you want to enter the error block
when the selected country does not match both cases, not whether you
don't match one or the other - that'll always be true.
Shawn
OMG! :) Sometimes I wonder how I dress myself. Thank you.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/