<
PUBLIC:COMPONENT id
=
"
bhvMaxlength
"
urn
=
"
maf:MaxLength
"
>
< PUBLIC:PROPERTY name = " MaxLength " />
< PUBLIC:ATTACH event = " onkeypress " handler = " doKeypress " />
< PUBLIC:ATTACH event = " onbeforepaste " handler = " doBeforePaste " />
< PUBLIC:ATTACH event = " onpaste " handler = " doPaste " />
< SCRIPT language = " JScript " >
// Keep user from entering more than MaxLength characters
function doKeypress()
{
if(!isNaN(MaxLength))
{
MaxLength = parseInt(MaxLength);
var oTR = element.document.selection.createRange();
// Allow user to type character if at least one character is selected
if(oTR.text.length >= 1)
event.returnValue = true;
else
if(value.length > MaxLength-1)
event.returnValue = false;
}
}
// Cancel default behavior
function doBeforePaste()
{
if(!isNaN(MaxLength))
event.returnValue = false;
}
// Cancel default behavior and create a new paste routine
function doPaste()
{
if(!isNaN(MaxLength))
{
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 >
< PUBLIC:PROPERTY name = " MaxLength " />
< PUBLIC:ATTACH event = " onkeypress " handler = " doKeypress " />
< PUBLIC:ATTACH event = " onbeforepaste " handler = " doBeforePaste " />
< PUBLIC:ATTACH event = " onpaste " handler = " doPaste " />
< SCRIPT language = " JScript " >
// Keep user from entering more than MaxLength characters
function doKeypress()
{
if(!isNaN(MaxLength))
{
MaxLength = parseInt(MaxLength);
var oTR = element.document.selection.createRange();
// Allow user to type character if at least one character is selected
if(oTR.text.length >= 1)
event.returnValue = true;
else
if(value.length > MaxLength-1)
event.returnValue = false;
}
}
// Cancel default behavior
function doBeforePaste()
{
if(!isNaN(MaxLength))
event.returnValue = false;
}
// Cancel default behavior and create a new paste routine
function doPaste()
{
if(!isNaN(MaxLength))
{
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 >