View Full Version : validation not working...why?!

10-03-2008, 09:24 PM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<script type="text/javascript" language="javascript">
function validatePizzaForm() {

if (isNaN(document.formPizza.txtBoxQuantity.value)) {
alert ("Please enter a quantity");
return false;
else if (!document.formPizza.radioSize_0.checked &&
!document.formPizza.radioSize_1.checked &&
!document.formPizza.radioSize_2.checked &&
alert("Please select a size of pizza");
return false;

return true;

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Chris' Pizza Shop</title>

<form id="formPizza" name="formPizza" method="post" action="">
<table width="100%" border="0">
<td colspan="2"><div align="center">Pizza Order Form</div></td>
<td width="50%"><div align="right">Quantity:</div></td>
<td width="50%"><label>
<input type="text" name="txtBoxQuantity" id="txtBoxQuantity" />
<td><div align="right">Size:</div></td>
<input type="radio" name="radioSize" value="10" id="radioSize_0" />
<br />
<input type="radio" name="radioSize" value="12" id="radioSize_1" />
<br />
<input type="radio" name="radioSize" value="14" id="radioSize_2" />
<br />
<input type="radio" name="radioSize" value="16" id="radioSize_3" />
Extra Large</label>
<br />
<td><div align="right">Ingredients:</div></td>
<td><select name="listBoxIngredients" id="listBoxIngredients">
<option value="Cheese" selected="selected">Cheese</option>
<option value="Sausage">Sausage</option>
<option value="Pepperoni">Pepperoni</option>
<option value="Mushroom">Mushroom</option>
<option value="Taco">Taco</option>
<td><div align="right">
<input type="submit" name="submit" id="submit" value="Submit" onclick="validatePizzaForm()" />
<input type="reset" name="Clear" id="Clear" value="Reset" />

I realize that you guys aren't here to do my homework, but the homework isn't the javascript it'll actually be PHP. I just don't understand where my javascript is off. I've gone through google several times, trying several searches. From what I've read, my code is correct. I'm probably missing like one little thing. Thanks for any help any one is willing to give me. A helpsite is my last resort [I spent 3 hours trying to figure out what was f$(#@& up with my code].

10-04-2008, 05:34 PM
<input type="submit" name="submit" id="submit" value="Submit" onclick="return validatePizzaForm()" />