MaxLength of a TextArea

admin

Administrator
Staff member
Hi.<br />
<br />
I'm working with several forms that post data directly to a database. I use some textareas, but I can't limit the character max length as I can do with a standard Input textbox.<br />
<br />
Does anyone knows how to determine the maxlength of a textarea?<br />
<br />
I use the textarea in order to have a multiline capability that inputs have not.<br />
<br />
I believe that a javascript that validates the length would be a good solution, but I'd prefer not to use a javascript.<br />
<br />
Please, if anyone knows... Help!<br />
<br />
Thank you. CybIRO. :confused:<!--content-->maxlength isn't possible with a text area. Your best bet is to use a javascript to check it AND add something serverside to check for those with javascript disabled.<!--content-->Thank You, anyway... I wish they could have a max length... I'll have to program that MaxLenght function.<br />
<br />
Why didn't realize of this need the HTML designers???<br />
<br />
Anyway. Thanx for your help.<br />
<br />
I wish I can help you back someday.<br />
<br />
CybIRO<!--content-->Shamless Plug (<!-- m --><a class="postlink" href="http://pauljunior.no-ip.com/research/max-length-check.php">http://pauljunior.no-ip.com/research/ma ... -check.php</a><!-- m -->)<br />
<br />
As Sam stated, you should also perform a check server side.<br />
<br />
Incase the link fails to work, as it might since that site is hosted off dial-up, I have attached the file.<!--content-->Thanks a lot!!!<br />
<br />
I have also added a server side validation in order to truncate the fields to the max allowed character length in the database.<br />
<br />
Thanks!!!<br />
<br />
CybIRO<br />
:D<!--content-->Paul, nice example. I just reworked it to behave more like the built in maxlength attrib for input's, and it works, however its a little finicky, and if you type quick enough and submit, you can submit before the javascript erases the extra characters. Any ideas for improvement?<!--content-->Change the onkeyup event handler to onkeydown. That also prevents the user from just holding down a key and submitting a few dozen lines of just one character.<!--content-->
 
Back
Top