Jump to content

Text area


user4fun

Recommended Posts

According to the w3c Specs, it appears that you can't. http://www.w3.org/TR/REC-html40/interact/f....html#h-17.13.1What you can do, however, is check the input using javascript before the form is submitted or with scripting after the form is submitted. If the length of the input is too long, present an error message and request new input.Alternately, deal with the supplied information in another fashion.

Link to comment
Share on other sites

<script type="text/javascript">function limit_chars(ele, number) {if (ele.value.length > number) {ele.value = ele.value.substr(0,number);}}</script><input type="text" onkeyup="limit_chars(this, 10)" />

The input box above will be limited to 10 characters.

Link to comment
Share on other sites

Note that with JS off, the textarea will have no limitation, so you should still scheck the textarea's lenght on the server. But that's a rule of thumb any time with forms, so... anyway.

Link to comment
Share on other sites

Yeah - never trust client-side form validation, because someone with a utility like FireBug for FireFox can always edit the code and successfully submit an invalid form. Always have server-side checking as a backup!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...