I want to show error below the text box based on input value checked with database value.
In the form
<div class="row">
<?php echo $form->labelEx($model,'Answer'); ?>
<?php echo $form->textField($model,'security_ans1',array('size'=>30,'maxlength'=>50)); ?>
<?php echo $form->error($model,'security_ans1'); ?></td>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton('Submit'); ?>
In the controller
if(isset($_POST['Security']))
{
$answer=$_POST['Security']['security_ans1'];
if($answer==$ans)
{
$this->redirect(array('/postRequest/default/index'));
}
else
{
$this->redirect('../../error');
}
}
Now the answer is incorrect it redirect to error page. but i want display error below the text box.