| <SCRIPT>
function clearField(field)
{
if (field.value == field.defaultValue)
field.value = "";
}
function checkField(field)
{
var Msg = "Sorry,
you need to be between 18 & 21";
if (field.name
== "age") {
//
only give an alert msg if the field is not empty && the age is
not between 18 and 21
if (field.value
!= "" && (field.value < 18) || (field.value
> 21)) {
alert("Invalid age.\n" +
Msg);
field.value = ""
}
}
if (field.value == "")
field.value = field.defaultValue;
}
</SCRIPT>
<FORM>
<INPUT
TYPE="text"
NAME="name"
VALUE="Name"
onFocus="clearField(this);"
onBlur="checkField(this);">
<INPUT
TYPE="text"
NAME="email"
VALUE="E-mail Address"
onFocus="clearField(this);"
onBlur="checkField(this);">
<INPUT
TYPE="text"
NAME="age"
VALUE="Your Age"
onFocus="clearField(this);"
onBlur="checkField(this);">
</FORM> |