function CheckMaxLength_OnKeyPress(txt,maxLength){
if(txt.value.length > (maxLength-1))
{
   if (window.event) 
      {
    	txt.value = txt.value.substr(0,maxLength);
    	window.event.returnValue = null;
	  }
}
}

function CheckMaxLength_OnPaste(txt,maxLength){
     if(maxLength){
		if (window.event) { 
          var oTR = txt.document.selection.createRange();
          var iInsertLength = maxLength - txt.value.length + oTR.text.length;
		  try {
          var sData = window.clipboardData.getData("Text").substr(0,iInsertLength);
          oTR.text = sData;
		  }
		  catch (err) {
		  }
          if (window.event) { 
			window.event.returnValue = null;
	 } else {
            txt.value = txt.value.substr(0,maxLength);
			return false;
		}
		}
	 }
}


