user4fun Posted September 15, 2007 Share Posted September 15, 2007 how can i limit the amount of information insered in a text area.? Link to comment Share on other sites More sharing options...
jlhaslip Posted September 15, 2007 Share Posted September 15, 2007 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 More sharing options...
user4fun Posted September 15, 2007 Author Share Posted September 15, 2007 Thank you, now ihav to go hunting for a js function that counts number of characters in a text field. lol Link to comment Share on other sites More sharing options...
Synook Posted September 16, 2007 Share Posted September 16, 2007 <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 More sharing options...
user4fun Posted September 17, 2007 Author Share Posted September 17, 2007 that is freaky and cool, it makes teh charcaters disappear after you go to the limit, that is coolThank you, i can think of some freaky stuff to do with that. Link to comment Share on other sites More sharing options...
jlhaslip Posted September 17, 2007 Share Posted September 17, 2007 Just in time for halloween, too... Link to comment Share on other sites More sharing options...
boen_robot Posted September 17, 2007 Share Posted September 17, 2007 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 More sharing options...
Synook Posted September 17, 2007 Share Posted September 17, 2007 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.