<public:component id="bhvMaxlength" urn="maf:Maxlength">
     <public:attach event="onkeypress" handler="doKeypress" />
     <public:attach event="onbeforepaste" handler="doBeforePaste" />
     <public:attach event="onpaste" handler="doPaste" />
     <!-- 
		Example of use:
		TEXTAREA { behavior: url(maxlength255.htc); } 
     -->
<script language="JScript">
	
	function doKeypress(){
		var maxLength = 4000;
		if(maxLength && value.length > maxLength-1){
			event.returnValue = false;
			maxLength = parseInt(maxLength);
		}
	}
	
	function doBeforePaste(){
		event.returnValue = false;
	}
	
	function doPaste(){
		var maxLength = 4000;
		event.returnValue = false;
		maxLength = parseInt(maxLength);
		var oTR = element.document.selection.createRange();
		var iInsertLength = maxLength - value.length + oTR.text.length;
		var sData = window.clipboardData.getData("Text").substr(0,iInsertLength);
		oTR.text = sData;
	}
</script>

</public:component>