View Full Version : Textarea in a Form
ks5922
07-31-2002, 10:12 PM
I have built a form which has a "textarea" to post the user's conclusions in. Now, I've been told the text in this area needs to be seen by the user, as it's written, and not "scrolled" into a hidden area. Also, when the form is printed out, all of the text needs to print.
Is there a way to "expand" the text box as the text is typed, yet limit the number of characters across (in order to keep within the printable margins)?:confused:
Please help if you can..... I've been working on this form over a month and am about to lose my job over this text box thing
Thanks
requestcode
08-01-2002, 02:52 PM
I don't believe you can easily exapand a text area to do that, but you can limit the number of characters they enter. Here is an example:
<html>
<head>
<title>Maximum Characters Form</title>
<SCRIPT LANGUAGE="JavaScript">
NS = document.layers? 1:0;
NS6=document.getElementById&&!document.all? 1:0;
IE=document.all? 1:0;
var maxcount=0
function KeyDown(e)
{
if (NS||NS6)
{var keycode = e.which // capture key pressed for netscape}
else
{var keycode = event.keyCode // capture key pressed for IE}
var len=document.myform.txta.value.length
if(len>=70 && keycode!='8' && keycode!="13") // if over 70 characters and not back space
{
window.status='Ok Ok thats it!'
alert('Please enter your response \r in 70 characters or less!')
return false
}
else
{
window.status='Keep Typing!'
}
}
</SCRIPT>
</head>
<body bgcolor="lightblue" onLoad="document.myform.txta.focus();document.myform.txta.select()">
<CENTER>
<H1><B>Maximum Characters</B></H1>
<FORM NAME="myform">
<TEXTAREA NAME="txta" COLS="30" ROWS="4" WRAP="hard" onKeyPress="return KeyDown(event)">Please keep your message 70 characters or less!</TEXTAREA>
</FORM>
</CENTER>
</body>
</html>
If you set the WRAP property to hard in the textarea tag that should keep them from going to the right to far.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.