Forum Moderators: coopster

Message Too Old, No Replies

How to colour fields if there is error? Simple question

         

toplisek

11:02 am on May 9, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hello,
I have problem how to do correct code with PHP:
1.colour text and input box if there is an error in form.

Need help.

I have the following code but it is wrong:
[PHP]
<?PHP (isset($error))? 'class=headingERROR' : 'class=headingCORRECT' ;?>
<input name="firstname" class="box" maxlength="30" size="20">
[/PHP]

Regards:)

phparion

11:51 am on May 9, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



<input name="firstname"
<?php echo (isset($error))? 'class=headingERROR' :
'class=headingCORRECT';?> maxlength="30" size="20">

kaleb

8:21 pm on May 9, 2007 (gmt 0)

10+ Year Member



toplisek,

Because you already have a css class assigned to the input box, I would handle it like this...


<?PHP
if ( isset($error) )
{
$css_class = ' headingERROR';
}
else
{
$css_class = ' headingCORRECT';
}
?>
<input name="firstname" class="box<?=$css_class?>" maxlength="30" size="20">