For standard HTML attribute information about the <TEXTAREA>
element, see the <TEXTAREA>
topic.
Currently, the <TEXTAREA>
element accepts four scripting attributes (at least as far as browser documentation is concerned). All four are mentioned in the Cougar W3C draft specification and are documented by both browsers support documentation, but the OnSelect
event appears not to be properly supported (by either browser).
OnBlur
As with all other scriptable elements, this event handler can be used to execute script functions when the control loses the users focus.
For example, the <TEXTAREA>
element below executes a script function that counts the number of characters entered in the text box when the focus is lost and alerts the user if they have typed too much into it :
The script function and OnBlur
event string are as follows :
<TEXTAREA NAME="descr" COLS="30" ROWS="3" OnBlur="count_char(document.egForm.descr.value)"> Enter a short description here (max 50 chars)
. . .
<SCRIPT LANGUAGE="VBScript">
<!--
Sub count_char(vStrValue)
vNumChar=len(vStrValue)
if vNumChar > 50 then alert "You have entered " & vNumChar & " characters, that's too many"
End Sub
-->
</SCRIPT>
As seen before, the event handler passes the value of the <TEXTAREA>
element (i.e. the text entered into it) to the function, which then determines the number of characters, and alerts the user if there are more than 50 characters in the text.
OnChange
This event handler can be used to run script functions whenever the user clicks in the <TEXTAREA>
element. If, for example, you require the user to fill in other form information before typing anything into the text box, then this event handler can be used to execute a script function to check the necessary elements before allowing the user to continue filling in the text box.
OnFous
OnFocus
can be used to execute script functions when the user focuses on the text box (by clicking in it, or tabbing into it (at least on Windows systems)).
OnSelect
Although this scripting attribute is documented by both Netscape and Internet Explorer support documentation (and is detailed in the Cougar W3C draft specification), it appears not to be fully supported. Theoretically it should run script functions when the user selects some text in the text box.