tnbrwneyez
Programmer
I need to take the following script and change the validate function so that after a messsage is displayed indicating that a field is wrong, the cursor is moved to that field.
<html>
<head>
<title>Form Example</title>
<Script language="JavaScript" type="text/javascript">
function validate() {
if (document.form1.yourname.value.length < 1){
alert("Please enter your full name.");
return false;
}
if (document.form1.address.value.length < 3) {
alert("Please enter your address.");
return false;
}
if (document.form1.phone.value.length < 3) {
alert("Please enter your phone number.");
return false;
}
return true;
}
</script>
</head>
<body>
<h1>Form Example</h1>
<p>Enter the following information. When you press the Submit button, the date you entered will
be validated, then sent by email. </p>
<form name="form1" action="mailto:user@host.com" enctype="text/plain"
method"POST" onSubmit="return validate();">
<p><b>Name:</b> <input TYPE="Text" size="20" name="yourname">
</p>
<p><b>Address:</b> <input TYPE="Text" size="30" name="address">
</p>
<p><b>Phone:</b> <input TYPE="Text" size="15" name="phone">
</p>
<p><input TYPE="Submit" Value="Submit"> </p>
</form>
</body>
</html>
Thanks!!!
<html>
<head>
<title>Form Example</title>
<Script language="JavaScript" type="text/javascript">
function validate() {
if (document.form1.yourname.value.length < 1){
alert("Please enter your full name.");
return false;
}
if (document.form1.address.value.length < 3) {
alert("Please enter your address.");
return false;
}
if (document.form1.phone.value.length < 3) {
alert("Please enter your phone number.");
return false;
}
return true;
}
</script>
</head>
<body>
<h1>Form Example</h1>
<p>Enter the following information. When you press the Submit button, the date you entered will
be validated, then sent by email. </p>
<form name="form1" action="mailto:user@host.com" enctype="text/plain"
method"POST" onSubmit="return validate();">
<p><b>Name:</b> <input TYPE="Text" size="20" name="yourname">
</p>
<p><b>Address:</b> <input TYPE="Text" size="30" name="address">
</p>
<p><b>Phone:</b> <input TYPE="Text" size="15" name="phone">
</p>
<p><input TYPE="Submit" Value="Submit"> </p>
</form>
</body>
</html>
Thanks!!!