Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

taLimit on a TEXTAREA in .net. Char limiter

Status
Not open for further replies.

pixel69

Technical User
Sep 25, 2002
56
ZA
I've tried to add a textarea limiter to my aspx page. This is currently what i have:
<ASP:TEXTBOX id="txtItemText" onkeypress="javascript:return taLimit()" onkeyup="javascript:return taCount(myCounter)" maxlength="4000" runat="server" textmode="MultiLine" rows="15" width="400px"></ASP:TEXTBOX>
You have <B><SPAN id=myCounter>4000</SPAN></B> characters remaining

And it doesn't seem to work. Obviously the related javascript is in place and it's working on one of my other ASP pages. Is the a specific one for ASPX?

Plz help!
Thanks
pixel
 
You can't use the maxlength property in a TextArea control. Try using something like:
Code:
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Page.RegisterClientScriptBlock("limittextarea", "<script>function setTextAreaLength(Object, MaxLength){return (Object.value.length <= MaxLength);}</script>")
        TextBox1.Attributes.Add("onkeypress", "return setTextAreaLength(this, 150);")
    End Sub


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top