How to dynamically set border to fieldset in yii framework during validation?
On failure the border of fieldset should turn RED, whereas on success the border of fieldset should turn GREEN..
If any one of the input fails the feildset should show failure and success if all elements are correct..
<fieldset class="field">
<div class="visible column">
<div>
<?php echo $form->labelEx( $modelAddress, 'First Name'); ?>
<?php echo $form->textField( $modelAddress, 'firstName'); ?>
<div class="indicator"> </div>
<?php echo $form->error( $modelAddress, 'firstName'); ?>
</div>
</div>
</fieldset>
//My Script
<script>
$(document).ready(function()
{ $("input").each(function(){if ($(this).hasClass("error"))
{ $(this).parent().parent().parent().parent().addClass("fieldseterror");
}
});
</script>
//PHP
<?php
$form = $this->beginWidget( 'CActiveForm', array(
'id' => 'registration',
'enableAjaxValidation' => true,
'clientOptions'=>array(
'validateOnSubmit'=>true,
'afterValidate' => 'js:checkErrors'
),'htmlOptions' => array( 'class' => 'vertical inner custom_frm_styl')));
?>
You can use jQuery.
Yii automatically changes non validating fields to have the class .error, so you can check if any of the form fields have the class .error to change whatever you want, eg (untested):