To support maxlength we have to call javascript function to restrict the number of characters.
Below example solve the above problem :
<script type="text/javascript">
function AdditionalInfoRestriction() {
var txtAddInfo = document.getElementById('<%=txtAdditionalInformation.ClientID %>');
try {
// 255 is maxlength of the textbox
if (txtAddInfo.value.length > 255) {
var cont = txtAddInfo.value;
txtAddInfo.value = cont.substring(0, 254);
return false;
}
}
catch (e) {
}
}
</script> if (txtAddInfo.value.length > 255) {
var cont = txtAddInfo.value;
txtAddInfo.value = cont.substring(0, 254);
return false;
}
}
catch (e) {
}
}
<asp:TextBox CssClass="txt" ID="txtAdditionalInformation"
onkeyup="return AdditionalInfoRestriction();"
Width="440px" TextMode="MultiLine" MaxLength="250" runat="server">
</asp:TextBox>
1 comment:
bài của bạn rất là tuyệt. xin cám ơn
Post a Comment