PDA

View Full Version : maximum characters in text area


ooiooipig
04-15-2003, 08:05 AM
Hi all, can anyone advise me on how can I set the maximum number of characters in a textarea?? I've done it in the way below, but it doesn't seem to work. It'll show me an error saying data truncated. Please advise!!
thanks.


<textarea rows="5" cols="108" name="vfuncReq" maxlength="1000" class="txtblack12"></textarea>

glenngv
04-15-2003, 09:18 AM
there's no maxlength property for textarea. you should validate in the server side if the length exceeds the maximum to ensure the saved data will not to be truncated.

ooiooipig
04-15-2003, 10:47 AM
ok thanks!! I've done it using the javascript in the client side...

glenngv
04-15-2003, 11:01 AM
but be sure to ALWAYS validate on the server since javascript can be bypassed.

whammy
04-18-2003, 04:27 PM
I do have a cross-browser textarea limiter though, in the case that the client has javascript enabled... it's called MaxText()...

Morgoth
04-19-2003, 03:50 AM
In ASP (more towards the topic of this forum), you grab the text and save it in a variable...

Then you can use the ASP function of getting the length of the string. len()

Once you get the len, you compair it to the max you set, and then if it's under let it go, if not, you do some sort of a error page.