﻿function doBeforePaste(control)
{
   maxLength = control.attributes["maxLength"].value;
   if(maxLength)
   {
       event.returnValue = false;
   }
}

function doPaste(control)
{
   maxLength = control.attributes["maxLength"].value;
   value = control.value;
   if(maxLength){
        event.returnValue = false;
        maxLength = parseInt(maxLength);
        var o = control.document.selection.createRange();
        var iInsertLength = maxLength - value.length + o.text.length;
        var sData = window.clipboardData.getData("Text").substr(0,iInsertLength);
        o.text = sData;
    }
}

function LimitInput(control)
{
    if(control.value.length > control.attributes["maxLength"].value) 
    {
        value = control.value;
        maxLength = control.attributes["maxLength"].value;
        maxLength = parseInt(maxLength);
        //var iInsertLength = maxLength - value.length + o.text.length;
        control.value = control.value.substr(0,control.attributes["maxLength"].value);
    }
}

