To view the terms under which this email is distributed, please go to
http://disclaimer.leedsmet.ac.uk/email.htm
On 22 October 2004 15:34, Stuart Felenstein wrote:
> I have rows of input fields
> Each row contains 3 fields. The user must fill out
> the entire row (all 3 fields) for things to work
> right.
>
> I want to generate an error in case they have only
> filled in 1 or 2 of the boxes.
>
> Thinking I might use something like this:
>
> foreach($skills as $key => $skill)
>
> {
> if ($skill != '' && $skys[$key] = '' &&
> $slus[$key] = '')
> {
>
> }else if{
> if ($skill = '' && $skys[$key] != '' &&
> $slus[$key] = '')
>
> }else{
> if ($skill = '' && $skys[$key] = '' && $slus[$key] != '')
>
> ..... above only takes into account that 1 of that 3
> has been filled in. I would need another set to take
> into account if 2 of the 3 have been filled in.
>
> Is there a simpler way / shorter way to check
> conditions to do this ?
So, the entry is valid only if all three are non-blank?
In which case:
if ($skill!='' && $skys[$key]!='' && $slus[$key] !='')
{
// row is valid -- do stuff
}
else
{
// entry has at least one value blank -- issue error
}
If you prefer to have the error path come first, simply apply deMorgan's
laws to the Boolean expression, to get:
if ($skills=='' || $skys[$key]=='' || $slus[$key]=='')
{
// entry has at least one value blank -- issue error
}
else
{
// row is valid -- do stuff
}
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS, LS6 3QS, United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php