Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 881
  • Last Modified:

How do I create a multiline non-scrolling textbox?

It needs to behave like a textarea but with absolutely no scrolling behaivors.
0
mccainz2
Asked:
mccainz2
  • 3
  • 2
1 Solution
 
JeffHowdenCommented:
By "absolutely no scrolling behaviors" do you mean it shouldn't have a scrollbar?  Or, do you mean that when enough text is entered to fill the available space in the textarea that no more is allowed to be added?

If it's the former, some simple styling can accomplish what you want:

<textarea style="overflow: auto"></textarea>

However, as soon as sufficient text is entered to fill the box, scrollbars will appear.

If you meant the latter, that'll require an immensely more complex solution.
0
 
mccainz2Author Commented:
...unfortunately the immensely more complex solution.
0
 
JeffHowdenCommented:
Oh boy.  I was hoping you weren't going to say that as I'm not even sure if it's possible.   Perhaps if I understood the need for this better, I could suggest something that is doable.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
mccainz2Author Commented:
I'm mimicing a standardized form that the user can fill out and print from the web. So, the fields for text entry are basically non scrolling boxes which correspond exactly to the sizes of the fields layed out on the old paper form.
0
 
mccainz2Author Commented:
Ive started looking at capturing keycodes within div tags that have been sized to the desired width and height, but the main problem I've run into with this approach is that the backspace button behaves badly (it causes the browser to go back to the last navigable page).
0
 
smaccariCommented:
Maybe this is a good starting point (IE only here though - but certainly not too hard to take a look for FF compliancy), using a textarea, the style attribute overflow Jeff spoke about, and simply by preventing default action (adding the key char in the textarea):

<script>
function checklength(obj)
{
      if (obj.value.length > parseInt(obj.cols)*parseInt(obj.rows)) event.returnValue = false;
}
</script>
<textarea style="overflow:hidden" rows=5 cols=20 onkeydown="checklength(this)"></textarea>

Need some tuning, but should work this way ;)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now