Text Object

By: aathishankaran Viewed: 153192 times  Printer Friendly Format    


For most tasks, the text object is the element you use most often to gather data entered by the user. The text object is used for capturing single-line, free-flow information. Which has the following syntax: 

<INPUT TYPE="text" [NAME="objectName"]

[VALUE="value"] [SIZE=size] [MAXLENGTH=size] [onBlur="methodName"] [onChange="methodName"] [onFocus="methodName"] [onSelect="methodName"]> 

For example, to define a text object for a last name, you could use the following: 

<INPUT TYPE="text" NAME=LastName SIZE=20 MAXLENGTH=25> 

Example 

<Html>

<Head>

<Title>

Text box Example

</Title>

<Body>

<H1>Example for TextBox</H1>

<Hr>

<Form Name=form1>

Name&nbsp;

<Input        Type=Text

Name=t1

Size=20

onFocus="alert('I have gained focus')"

onBlur="alert('I have Lost the focus')"

onSelect="alert('You have selected text')"

onChange="alert ('You have changed some data')"

>

<Br>

E-Mail

<Input type=Text Size=20>

<Hr>

 </Form>

</Body>

</Html>

 

Output 

 

If the first text box gets the control then, an alert box is displayed

 If the first text box looses the control then, an alert box is displayed.

 If the text in the text box is selected then, an alert box is displayed

If some data is changed then another alert is displayed

 



Most Viewed Articles (in JSP )

Latest Articles (in JSP)

Comment on this tutorial