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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get the size of a textarea element?

Status
Not open for further replies.

Brett123

Programmer
May 15, 2000
4
US
I'm probably just overlooking something simple, but is there a way to get the size (i.e. the number of characters) of a TEXTAREA element?&nbsp;&nbsp;Or a way to set the maximum size like the MAXLENGTH property of input text fields?&nbsp;&nbsp;I haven't been able to find any commands like this.<br><br>Thanks in advance, Brett
 
&nbsp;&nbsp;Simple, just use the following arguments, 'size' & 'maxlength'. If for instance, wanted a text field with only 24 characters visible, but with a maximum of 50 characters, it would look like this.<br><br>&lt;input type=&quot;text&quot; name=&quot;textfield&quot; size=&quot;24&quot; maxlength=&quot;50&quot;&gt;<br><br>&nbsp;&nbsp;&nbsp;With these two arguments at your disposal, you will be able to create any type of fields you like.<br><br>Hope it helps. <p>Andre Vandal<br><a href=mailto:dezign@canada.com>dezign@canada.com</a><br><a href= Dezign's Sites</a><br>A bit of eveything Celestial
 
Thanks Andre, but I actually needed the element to be a textarea, because the user can submit up to a full page of text.&nbsp;&nbsp;I was able to do a simple validation using javascript by getting the value of the textarea element and then checking it's length to make sure it wasn't too long.&nbsp;&nbsp;Thanks again though for your suggestion.<br><br>Brett
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top