Textarea Character Counter In Forms

i have javascript code for textarea.

how to use this code in Textarea field item in a form using cactiveform .??

plz reply

<script type="text/javascript" src="http://www.google.com/jsapi"></script>  





<script type="text/javascript" language="javascript">  


google.load("jquery", "1.4.2");  





var characterLimit = 150;  





google.setOnLoadCallback(function(){  


  	


	$('#remainingCharacters').html(characterLimit);  


  	


	$('#myTextarea').bind('keyup', function(){  


    	var charactersUsed = $(this).val().length;  


      	


    	if(charactersUsed > characterLimit){  


        	charactersUsed = characterLimit;  


        	$(this).val($(this).val().substr(0, characterLimit));  


        	$(this).scrollTop($(this)[0].scrollHeight);  


    	}  


      	


    	var charactersRemaining = characterLimit - charactersUsed;  


      	


    	$('#remainingCharacters').html(charactersRemaining);  


	});  


});  


</script>

You could create YII widget for this purpose - http://www.yiiframework.com/doc/guide/1.1/en/basics.view#widget . Try to understand what is there and ask questions that you will have after that.