i have used 'enableclientvalidation'=>true, in yii active form enable client side validation.it works fine want display error message in instead of under field. worked according yii. how add css "error" class input on form submit? code adds error_input class on textfield error still appears under textfield. should appreciated.
my code
<?php $form = $this->beginwidget('cactiveform', array( 'id'=>'contact-form', 'enableclientvalidation'=>true, 'clientoptions'=>array( 'validateonsubmit'=>true, 'aftervalidate' => 'js:function(form, data, haserror) { if(haserror) { for(var in data) $("#"+i).addclass("error_input"); return false; } else { form.children().removeclass("error_input"); return true; } }', 'aftervalidateattribute' => 'js:function(form, attribute, data, haserror) { if(haserror) $("#"+attribute.id).addclass("error_input"); else $("#"+attribute.id).removeclass("error_input"); }' ), )); ?> <div class="margin-bottom3 label-width1"> <?php echo $form->labelex($customer,'restaurant_name',array('class'=>'label-texts')); ?></div> <div class="name-common-div"> <?php echo $form->textfield($customer,'restaurant_name',array('class'=>'text-background customer_fields')) ?> <?php echo $this->msg; echo $form->error($customer,'restaurant_name',array('class'=>'check-add-member-error')); ?> </div> how can this?`
you might wanna @ bootstrap extension yii (http://www.yiiframework.com/extension/bootstrap/). allows use placeholder want, should easier rather creating own css.
Comments
Post a Comment