限制文本框输入长度
function Count(text,long)
{
var maxlength = new Number(long); // Change number to your max length.
if(document.getElementById('<%=textBox.ClientID%>').value.length > maxlength){
text.value = text.value.substring(0,maxlength);
alert(" Only " + long + " chars");
}
Where “textBox” is the asp text box ID.
Also add following events in your textbox.
onKeyUp="javascript:Count(this,200);" onChange="javascript:Count(this,200);"
Your textbox code should look like
<asp:TextBox ID="textBox" onKeyUp="javascript:Count(this,2);" onChange="javascript:Count(this,2);" TextMode=MultiLine Columns="5" Rows="5" runat=server>
</asp:TextBox>
浙公网安备 33010602011771号