FrustratedStudent Posted March 20, 2011 Share Posted March 20, 2011 I have seen textfield boxes on forms that have a scrollbar on the side and are seemingly limitless on the number of rows it will allow. How is that done? I know how to limit the number of rows or columns, but that is leaving me with a huge ugly textbox when I would really like to have a nice small one...If I don't make any specifications I end up with a odd small box that won't work for what I want. Suggestions? Link to comment Share on other sites More sharing options...
Ingolme Posted March 20, 2011 Share Posted March 20, 2011 To my knowledge, a textarea doesn't have a limit on the amount of text allowed in it. If the rows don't fit in the area of the box a scrollbar will be added. Link to comment Share on other sites More sharing options...
Fmdpa Posted March 20, 2011 Share Posted March 20, 2011 To my knowledge, a textarea doesn't have a limit on the amount of text allowed in it.HTML5 will change that: http://www.w3schools.com/html5/tag_textarea.aspCurrently, you could do the same thing with JS though (untested):<textarea rows="5" cols="30" id="ta"></textarea><script>ta = document.getElementById('ta');max_characters = 250;ta.onkeypress = function(evt) { evt = evt ? evt : window.event; if (evt.keyCode) code = evt.keyCode; else if (evt.which) code = evt.which; else return false; // if the textarea is at its maximum length limit then only allow the delete, enter and backspace keys (In other words, nothing can be added); if ((code != 8 && code != 13 && code != 46) && ta.value.length > max_characters) { return false; // prevent the default action (printing the character); }}</script> This can be bypassed by disabling Javascript, so it is purely an enhancement for the majority of users. Link to comment Share on other sites More sharing options...
FrustratedStudent Posted March 20, 2011 Author Share Posted March 20, 2011 Thanks, to both of you! I thought that by limiting the number of rows showing it would limit the input as well. I'm not ready for script just yet, I'm still getting myself confused with html, lol!Thanks again for the help! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.