My form validates all fields successfully, but I want to remove the CSS error class when everything is OK.
All of my fields validate on change, but the below only pops up a dialog saying "Got a problem!", even when I correct any errors. If I erase the field and type in some other garbage, it reports a problem again.
I even moved the alert call out of the conditional, but it never resolves if I change the field to hold the correct content.
Since success is never reported, the error style on the field never goes away.
Why is this happening?
$form = $this->beginWidget('CActiveForm', array(
'id'=>'treeForm',
'enableAjaxValidation'=>true,
'enableClientValidation'=>true,
'clientOptions'=>array(
'validateOnChange'=>true,
)
));
//...stuff was here...
echo $form->error($model,'odds_sj', array(
'afterValidateAttribute' => 'js:function(form, attribute, data, hasError)
{
if (!hasError)
{
alert("All good!");
}
else
{
alert("Got a problem!");
}
}'
));