Java Reference
In-Depth Information
Figure 7-5
This example does not work properly on Firefox; we'll discuss this shortly.
Within the body of the page, you create the HTML elements that defi ne your form. Inside your form, which
is called form1, you create three form elements with the names txtName, txtAge, and btnCheckForm.
<form action=”“ name=”form1”>
Please enter the following details:
<p>
Name:
<br />
<input type=”text” name=”txtName” onchange=”txtName_onchange()“ />
</p>
<p>
Age:
<br />
<input type=”text” name=”txtAge” onblur=”txtAge_onblur()“
size=”3” maxlength=”3” />
</p>
<p>
<input type=”button” value=”Check Details”
name=”btnCheckForm” onclick=”btnCheckForm_onclick()“>
</p>
</form>
You'll see that for the second text box (the txtAge text box), you have included the size and maxlength
attributes inside the <input/> element. Setting the size attribute to 3 gives the user an idea of how
much text you are expecting, and setting the maxlength attribute to 3 helps ensure that you don't get
overly large numbers entered for the age value.
Search WWH ::




Custom Search