Welcome Guest, Not a member yet? Register   Sign In
Form Validation Errors
#3

[eluser]Simian Studios[/eluser]
[quote author="_steve" date="1276574179"]styling the individual fields which failed validation.
Any suggestions?[/quote]

So, you want to apply a class to the actual form input itself, if I understand correctly.

Not sure if this is the "correct" way to do it, but it will work..

Code:
<input type="text" name="name" id="name"<?php if(form_error('name') !== ''){ ?> class="error" <?php } ?>value="<?php echo set_value('name'); ?>" />

The trick is that form_error() will return a string if there is an error, or a null value if not, so we can test against that and set the class accordingly.


Messages In This Thread
Form Validation Errors - by El Forum - 06-14-2010, 04:56 PM
Form Validation Errors - by El Forum - 06-14-2010, 11:24 PM
Form Validation Errors - by El Forum - 06-15-2010, 02:05 AM
Form Validation Errors - by El Forum - 06-15-2010, 12:14 PM
Form Validation Errors - by El Forum - 06-16-2010, 04:07 AM



Theme © iAndrew 2016 - Forum software by © MyBB