Go Back   CodingForums.com > :: Client side development > JavaScript programming > DOM and JSON scripting

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-03-2008, 08:24 PM   PM User | #1
razorbladekiss
New to the CF scene

 
Join Date: Mar 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
razorbladekiss is an unknown quantity at this point
validation not working...why?!

Code:
<!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">
<head>

<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 &&
			 !document.formPizza.radioSize_3.checked){
		alert("Please select a size of pizza");
		return false;
	} 
	
	return true;
}
</script>

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

<body>
<form id="formPizza" name="formPizza" method="post" action="">
  <table width="100%" border="0">
    <tr>
      <td colspan="2"><div align="center">Pizza Order Form</div></td>
    </tr>
    <tr>
      <td width="50%"><div align="right">Quantity:</div></td>
      <td width="50%"><label>
        <input type="text" name="txtBoxQuantity" id="txtBoxQuantity" />
      </label></td>
    </tr>
    <tr>
      <td><div align="right">Size:</div></td>
      <td><p>
        <label>
          <input type="radio" name="radioSize" value="10" id="radioSize_0" />
          Small</label>
        <br />
        <label>
          <input type="radio" name="radioSize" value="12" id="radioSize_1" />
          Medium</label>
        <br />
        <label>
          <input type="radio" name="radioSize" value="14" id="radioSize_2" />
          Large</label>
        <br />
        <label>
          <input type="radio" name="radioSize" value="16" id="radioSize_3" />
          Extra Large</label>
        <br />
      </p></td>
    </tr>
    <tr>
      <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>
      </select></td>
    </tr>
    <tr>
      <td><div align="right">
        <label>
        <input type="submit" name="submit" id="submit" value="Submit" onclick="validatePizzaForm()" />
        </label>
      </div></td>
      <td><label>
        <input type="reset" name="Clear" id="Clear" value="Reset" />
      </label></td>
    </tr>
  </table>
</form>
</body>
</html>
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].
razorbladekiss is offline   Reply With Quote
Old 10-04-2008, 04:34 PM   PM User | #2
shyam
Senior Coder

 
shyam's Avatar
 
Join Date: Jul 2005
Posts: 1,563
Thanks: 2
Thanked 163 Times in 160 Posts
shyam will become famous soon enough
Code:
<input type="submit" name="submit" id="submit" value="Submit" onclick="return validatePizzaForm()" />
__________________
You never have to change anything you got up in the middle of the night to write. -- Saul Bellow
shyam is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:18 AM.


Advertisement
Log in to turn off these ads.