sphinx3212000
08-09-2003, 06:55 PM
For some reason im not getting any of the alerts to come up for my form validation when i try to submit this form...here is the code...any help would be appreciated:
<html>
<head>
<title>Basic Form Validation</title>
<script>
<!--
function validate ()
{
if (document.forms.order.CustomerName.value == " ") {
alert("Please enter your name.")
return false;
}
if (documents.forms.order.CustomerID.value == " ") {
alert("Please enter your Customer ID.")
return false;
}
if (document.forms.order.Qty.value <= 0) {
alert("Please enter a positive number of gadgets.")
return false;
}
return true;
}
// -->
</script>
</head>
<body>
<h1 align="center">Gadget Order Form</h1>
<hr>
<form name="order" method="POST" action="mailto:johndoe@aol.com" onsubmit="return validate()">
<b>Customer Name: </b>
<input type="text" name="CustomerName" id="CustomerName" size="25" maxlength="35">
<br><br>
<b>Customer ID:</b>
<input type="password" name="CustomerID" id="CustomerID" size="8" maxlength="8">
<br><br>
<b>Quantitiy of Gadgets:</b>
<input type="text" name="Qty" id="Qty" size="2" maxlength="2">
<input type="submit" value="order">
<input type="reset" value="reset">
</form>
</body>
</html>
<html>
<head>
<title>Basic Form Validation</title>
<script>
<!--
function validate ()
{
if (document.forms.order.CustomerName.value == " ") {
alert("Please enter your name.")
return false;
}
if (documents.forms.order.CustomerID.value == " ") {
alert("Please enter your Customer ID.")
return false;
}
if (document.forms.order.Qty.value <= 0) {
alert("Please enter a positive number of gadgets.")
return false;
}
return true;
}
// -->
</script>
</head>
<body>
<h1 align="center">Gadget Order Form</h1>
<hr>
<form name="order" method="POST" action="mailto:johndoe@aol.com" onsubmit="return validate()">
<b>Customer Name: </b>
<input type="text" name="CustomerName" id="CustomerName" size="25" maxlength="35">
<br><br>
<b>Customer ID:</b>
<input type="password" name="CustomerID" id="CustomerID" size="8" maxlength="8">
<br><br>
<b>Quantitiy of Gadgets:</b>
<input type="text" name="Qty" id="Qty" size="2" maxlength="2">
<input type="submit" value="order">
<input type="reset" value="reset">
</form>
</body>
</html>