[eluser]Samus[/eluser]
i'm trying to add a class depending on whether my input elements have passed validation and can't quite think how to do this.
Here's a snippet of my view:
Code:
<span class="formf <?= (form_error(('content')) ? "control-group error" : ""); ?>">
<?=form_label('Content', 'fcontent');?>
<?= form_error('content', '<div class="error_message">', '</div>'); ?>
<?=form_textarea(array('name' => 'content', 'value' => set_value('content'), 'id' => 'fcontent', 'rows' => 3, 'title' => 'Content shit here'));?>
</span>
When the validation is run, and an input element does not pass validation the classes 'control-group error' is appended on the span tag. That works all fine an dandy.
But what I want it to do is check if an input element has passed validation and if it has then append the classes 'control-group success' on the span element.
But obviously on page load, because no errors were returned it will append 'control-group success'.
How would I make it so that it only does that after the element has gone through validation?
Or can somebody suggest another method of doing this?