Hey,
i was wondering if there is a way to set the input background color when there is an error in the client side.
currently it changes the div that contains the input?
Thanks,
Hey,
i was wondering if there is a way to set the input background color when there is an error in the client side.
currently it changes the div that contains the input?
Thanks,
if u use jquery you can change the color like this
$("#myTextBoxID").attr("style","color:red;");
if you not use jquery
var object=document.getElementById("myTextBoxId");
object.style="color:red;";
Thanks, but i want to change it when there is an error, and i am using Yii validation. so i need to know when the validation is done, and there is an error.
is there a way to know it?
of course…
like in yii standard login form right?
i think you could use firebug and analyze it…
You can modify yiiactiveform.js to add class to input instead of container. Here’s what needs to be changed:
[list=1]
[*]Copy jquery.yiiactiveform.js from framework/web/js/source/ folder to js subfolder of your HTML root folder
[*]Edit jquery.yiiactiveform.js (line 218):
change
var $container = $.fn.yiiactiveform.getInputContainer(attribute, form);
to
var $container = $('#'+attribute.inputID);
[*]Remap jquery.yiiactiveform.js to modified one. To do this, modify scriptMap of client script somewhere in your application:
Yii::app()->clientScript->scriptMap = array('jquery.yiiactiveform.js' => Yii::app()->request->baseUrl.'/js/jquery.yiiactiveform.js');
[/list]