Wednesday, August 26, 2009

Character Left

<asp:TextBox ID="txtDescription" ToolTip="Document Type Description runat="server TextMode="MultiLine" MaxLength="400"
Height="60px"></asp:TextBox>

<asp:Label ID="lblCharLeft" Width="20px" runat="server"
Text
="400" Font-Bold="true
ToolTip="Description Character Left"></asp:Label>

txtDescription.Attributes.Add("onkeyup", "javascript:return
CharLeft(this,'lblCharLeft',"
+ txtDescription.MaxLength +
",'blueViolet','red')"
);

function CharLeft(object,lblCharLeft,maxVal,NormalColor,maxValExceedColor)

{

var ValLen=object.value.length;

var lblCharLeft=document.getElementById(GetClientId(lblCharLeft));

setLabelText(lblCharLeft,maxVal-ValLen)

if(getLabelText(lblCharLeft)<0)

{

var v=object.value.substring(0,maxVal);

setLabelText(lblCharLeft,0)

object.value= v;

lblCharLeft.style.color=maxValExceedColor;

}

else

{

lblCharLeft.style.color=NormalColor;

}

}

No comments:

Post a Comment