I have a working javascript function checking the character count in a TextBox of a webform, being called with onChange. The alert notifies the user of the character limit and the current character count, so the inclination is to reduce the number of characters after clicking ok on the alert. However, onChange will not function at this point.
I would like suggestions on how my function can be called continuously while the character count remains over the limit (and the user increments downwards based upon the character count feedback.
My function:
<script type="text/javascript">
function CountDesc(text,long)
{
var maxlength = new Number(long);
var count = text.value.length;
if (count > maxlength){
text.value = text.value.substring(0,maxlength);alert("Incident Description may
only contain " + long + " characters.\nCurrent character count is: " + count);
}
}
My function Call:
<asp:TextBox ID="txtDescription" runat="server" Height="80px" TextMode="MultiLine"
Width="680px" MaxLength="1000" TabIndex="33" onChange="CountDesc(this,1000)"></asp:TextBox>
Thanks.