View Full Version : Simple but I'm stumped
AndyD
08-18-2000, 03:43 PM
Hi folks, a simple question for you I'm sure I have text area box on my site with scroll bars. I want to remove the scroll bars to limit the amount of text tha can be input into this field the code I have for the box is as follows
<!-- start of my code-->
<TD WIDTH="250"><FONT FACE="ARIAL" SIZE="2"> <TEXTAREA NAME="SHIPUSERDEFINED" ROWS="5" COLS="40"
VALUE="NETQUOTEVAR:SHIPUSERDEFINED"></TEXTAREA>
<!-- end of my code-->
What do I need to add to remove the scroll option and limit the text. Is the a Noscroll tag?
Any help appreciated.
Regards AndyD[nbsp]
Phil Chaney
08-18-2000, 08:24 PM
Unfortunately there is no attribute that can be added to the TEXTAREA tag to remove the scroll bars and unlike the TEXT tag, the number of characters cannot be set to a maximum lenth.[nbsp][nbsp]The scrollbars are a function of the tag.
The only option you could try, though somewhat crude, is to use a Javascript that counts the number of characters as you type them into the text area and either displays that number or pops up a flag when the limit is reached.[nbsp][nbsp]Many of the wireless carriers that use forms for sending text messages over web employ scripts to track the number of characters to limit the message size.
Phil
mike_w
08-19-2000, 02:14 PM
Since the place where I work is short on production staff I've been doing alot of html and JavaScript lately. So, I'll take this as an opportunity to practice my JavaScript.
The following example will check a textarea for the number of characters, alert if the maximum characters is exceeded and then "trim" the entered text. It uses 2 methods -
onChange - to handle pasted text
onKeyUp - to check typed text
Only tested with IE5, sorry have to run to the store to get groceries ;)[nbsp][nbsp][nbsp][nbsp]
<html>
<head>
<title>teaxtarea limiting test</title>
<script language = "JavaScript">
<!--
function checkText(text,maxChars) {
[nbsp][nbsp]if(text.length > maxChars) {
[nbsp][nbsp][nbsp][nbsp]alert('There is a limit of ' + maxChars + ' characters for this textarea, extra characters will be trimmed.')
[nbsp][nbsp][nbsp][nbsp]var choppedText = text.substr(0, maxChars)
[nbsp][nbsp][nbsp][nbsp]document.testForm.myText.value = choppedText
[nbsp][nbsp][nbsp][nbsp]return false
[nbsp][nbsp]}
}
//-->
</script>
</head>
<body>
<form name="testForm">
<textarea name="myText" cols="40" rows="6" onChange="checkText(this.value,20)" onKeyUp="checkText(this.value,20)">
</textarea>
</form>
</body>
</html>
[This message has been edited by mike_w (edited 08-19-00@2:29 pm)]
Keiichi
08-26-2000, 08:23 PM
i thought you can do that. throw in the word "nowrap" (w/o the quotes) and put maxlength="#" inside the tag
------------------
K1
Phil Chaney
08-27-2000, 12:19 AM
i thought you can do that. throw in the word "nowrap" (w/o the quotes) and put maxlength="#" inside the tag
The NOWRAP is an attribute of the TEXTAREA element, but MAXLENGTH will not work, as it is an attribute only for the INPUT TYPE="text" element/attribute set.[nbsp]
vBulletin® v3.6.8, Copyright ©2000-2012, Jelsoft Enterprises Ltd.