Translate

Tuesday, 5 September 2017

validate max length in asp text box having multi line as well as text area in html


for test use this
<div>
        <asp:TextBox ID="txtAddresss" TextMode="MultiLine"  onchange="if (this.value.length > 1) {alert('onchange event');this.value=this.value.substring(0,1); return false; }"  onkeypress="if (this.value.length > 1) {alert('onkeypress event');this.value=this.value.substring(0,1); return false; }" runat="server"></asp:TextBox>
        <br /><textarea id="txtAddresss1"  onchange="if (this.value.length > 1) {alert('onchange event');this.value=this.value.substring(0,1); return false; }"  onkeypress="if (this.value.length > 1) {alert('onkeypress event');this.value=this.value.substring(0,1); return false; }"></textarea>
    </div>


For Implementation use this


        <asp:TextBox ID="txtAddresss" TextMode="MultiLine"  onchange="if (this.value.length > 1) {alert('onchange event');this.value=this.value.substring(0,1); return false; }"  onkeypress="if (this.value.length > 1) {this.value=this.value.substring(0,1); return false; }" runat="server"></asp:TextBox>
        <br /><textarea id="txtAddresss1"  onchange="if (this.value.length > 1) {alert('onchange event');this.value=this.value.substring(0,1); return false; }"  onkeypress="if (this.value.length > 1) {this.value=this.value.substring(0,1); return false; }"></textarea>

No comments:

Post a Comment