7Priest7
June 26th, 2007, 03:47 PM
if(FormN.phone.value!=/^\(?\d{3}[\)-]?\s?\d{3}[\s-]?\d{4}$/) {alert("Phone # is Formed Incorrectly!!!"); hold=false;}
It is supposed to look for a phone number in the following forms
nnn-nnn-nnnn
(nnn) nnn-nnnn
nnn nnn nnnn
I believe the above is wrong but heres the full code
<html>
<head>
<title>Wizard Works -- Order Form</title>
<script type="text/javascript">
function priceC()
{
var FormN = document.forms["form1"];
var prices=0;
if (FormN.GPF.checked==true) {prices+=(parseInt(FormN.GPFQ.value)*3.50);}
if (FormN.SC.checked==true) {prices+=(parseInt(FormN.SCQ.value)*4.95);}
if (FormN.GC.checked==true) {prices+=(parseInt(FormN.GCQ.value)*6.95);}
if (FormN.GS.checked==true) {prices+=(parseInt(FormN.GSQ.value)*9.95);}
if (FormN.FK.checked==true) {prices+=(parseInt(FormN.FKQ.value)*19.95);}
if (FormN.FKD.checked==true) {prices+=(parseInt(FormN.FKDQ.value)*29.95);}
if (FormN.GF.checked==true) {prices+=(parseInt(FormN.GFQ.value)*39.95);}
prices+=parseFloat(FormN.Ship.value);
FormN.price.value='$' + prices.toFixed(2);
FormN.price.disabled=true;
FormN.submit.type="submit";
}
function ResetF()
{
var FormN = document.forms["form1"];
FormN.submit.type="hidden";
FormN.price.value="Price Check";
FormN.price.disabled=false;
}
function Verify()
{
var hold=true;
var FormN = document.forms["form1"];
if(FormN.fname.value.length==0){alert("You need a first name!!!"); hold=false;}
if(FormN.lname.value.length==0){alert("You need a last name!!!"); hold=false;}
if(FormN.address.value.length==0){alert("You need a address!!!"); hold=false;}
if(FormN.phone.value.length==0){alert("You need a phone!!!"); hold=false;}
if(FormN.CCN.value.length==0){alert("You need a Credit Card!!!"); hold=false;}
if(FormN.CCD.value.length==0){alert("You need a Credit Card!!!"); hold=false;}
if(FormN.phone.value!=/^\(?\d{3}[\)-]?\s?\d{3}[\s-]?\d{4}$/) {alert("Phone # is Formed Incorrectly!!!"); hold=false;}
return hold;
}
</script>
</head>
<body>
<img src="logo.jpg" />
<form action="done.htm" method="post" name="form1" id="form1"><br />
First Name: <input type="text" id="fname" name="fname" /><br />
Last Name: <input type="text" id="lname" name="lname" /><br />
Address: <input type="text" id="address" name="address" /><br />
Phone Number: <input type="text" id="phone" name="phone" /><br />
Credit Card Type:
<select id="CCT" name="CCT">
<option value="AE">American Express</option>
<option value="DC">Diners Club</option>
<option value="Dr">Discover</option>
<option value="MC">Master Card</option>
<option value="Va">Visa</option>
</select><br />
Credit Card #: <input type="text" id="CCN" name="CCN" /><br />
Credit Card Expiration Date: <input type="text" id="CCD" name="CCD" /><br />
<br />
<hr />
<br />
Fountains: <br />
Green/Purple Fountain: $3.50 ea. <input type="checkbox" name="GPF" id="GPF" /> Qty: <input type="text" name="GPFQ" id="GPFQ" /><br />
Silver Cone: $4.95 ea. <input type="checkbox" name="SC" id="SC" /> Qty: <input type="text" name="SCQ" id="SCQ" /><br />
Glitter Cone: $6.95 ea. <input type="checkbox" name="GC" id="GC" /> Qty: <input type="text" name="GCQ" id="GCQ" /><br />
Glittering Stars: $9.95 ea. <input type="checkbox" name="GS" id="GS" /> Qty: <input type="text" name="GSQ" id="GSQ" /><br />
Fountain Kit: $19.95 ea. <input type="checkbox" name="FK" id="FK" /> Qty: <input type="text" name="FKQ" id="FKQ" /><br />
Fountain Kit Deluxe: $29.95 ea. <input type="checkbox" name="FKD" id="FKD" /> Qty: <input type="text" name="FKDQ" id="FKDQ" /><br />
Giant Fountain: $39.95 ea. <input type="checkbox" name="GF" id="GF" /> Qty: <input type="text" name="GFQ" id="GFQ" /><br />
Shipment Method:
<select id="Ship" name="Ship">
<option value="4.95">Standard $4.95</option>
<option value="8.95">Express $8.95</option>
<option value="12.95">Next Day $12.95</option>
</select><br />
<input onClick="return Verify()" name="submit" id="submit" type="submit" value="Submit" /><input type="reset" value="Reset" onClick="ResetF();" /><input name="price" id="price" type="button" value="Price Check" onClick="priceC();" />
</body>
</html>
Please and Thank You
Alex
It is supposed to look for a phone number in the following forms
nnn-nnn-nnnn
(nnn) nnn-nnnn
nnn nnn nnnn
I believe the above is wrong but heres the full code
<html>
<head>
<title>Wizard Works -- Order Form</title>
<script type="text/javascript">
function priceC()
{
var FormN = document.forms["form1"];
var prices=0;
if (FormN.GPF.checked==true) {prices+=(parseInt(FormN.GPFQ.value)*3.50);}
if (FormN.SC.checked==true) {prices+=(parseInt(FormN.SCQ.value)*4.95);}
if (FormN.GC.checked==true) {prices+=(parseInt(FormN.GCQ.value)*6.95);}
if (FormN.GS.checked==true) {prices+=(parseInt(FormN.GSQ.value)*9.95);}
if (FormN.FK.checked==true) {prices+=(parseInt(FormN.FKQ.value)*19.95);}
if (FormN.FKD.checked==true) {prices+=(parseInt(FormN.FKDQ.value)*29.95);}
if (FormN.GF.checked==true) {prices+=(parseInt(FormN.GFQ.value)*39.95);}
prices+=parseFloat(FormN.Ship.value);
FormN.price.value='$' + prices.toFixed(2);
FormN.price.disabled=true;
FormN.submit.type="submit";
}
function ResetF()
{
var FormN = document.forms["form1"];
FormN.submit.type="hidden";
FormN.price.value="Price Check";
FormN.price.disabled=false;
}
function Verify()
{
var hold=true;
var FormN = document.forms["form1"];
if(FormN.fname.value.length==0){alert("You need a first name!!!"); hold=false;}
if(FormN.lname.value.length==0){alert("You need a last name!!!"); hold=false;}
if(FormN.address.value.length==0){alert("You need a address!!!"); hold=false;}
if(FormN.phone.value.length==0){alert("You need a phone!!!"); hold=false;}
if(FormN.CCN.value.length==0){alert("You need a Credit Card!!!"); hold=false;}
if(FormN.CCD.value.length==0){alert("You need a Credit Card!!!"); hold=false;}
if(FormN.phone.value!=/^\(?\d{3}[\)-]?\s?\d{3}[\s-]?\d{4}$/) {alert("Phone # is Formed Incorrectly!!!"); hold=false;}
return hold;
}
</script>
</head>
<body>
<img src="logo.jpg" />
<form action="done.htm" method="post" name="form1" id="form1"><br />
First Name: <input type="text" id="fname" name="fname" /><br />
Last Name: <input type="text" id="lname" name="lname" /><br />
Address: <input type="text" id="address" name="address" /><br />
Phone Number: <input type="text" id="phone" name="phone" /><br />
Credit Card Type:
<select id="CCT" name="CCT">
<option value="AE">American Express</option>
<option value="DC">Diners Club</option>
<option value="Dr">Discover</option>
<option value="MC">Master Card</option>
<option value="Va">Visa</option>
</select><br />
Credit Card #: <input type="text" id="CCN" name="CCN" /><br />
Credit Card Expiration Date: <input type="text" id="CCD" name="CCD" /><br />
<br />
<hr />
<br />
Fountains: <br />
Green/Purple Fountain: $3.50 ea. <input type="checkbox" name="GPF" id="GPF" /> Qty: <input type="text" name="GPFQ" id="GPFQ" /><br />
Silver Cone: $4.95 ea. <input type="checkbox" name="SC" id="SC" /> Qty: <input type="text" name="SCQ" id="SCQ" /><br />
Glitter Cone: $6.95 ea. <input type="checkbox" name="GC" id="GC" /> Qty: <input type="text" name="GCQ" id="GCQ" /><br />
Glittering Stars: $9.95 ea. <input type="checkbox" name="GS" id="GS" /> Qty: <input type="text" name="GSQ" id="GSQ" /><br />
Fountain Kit: $19.95 ea. <input type="checkbox" name="FK" id="FK" /> Qty: <input type="text" name="FKQ" id="FKQ" /><br />
Fountain Kit Deluxe: $29.95 ea. <input type="checkbox" name="FKD" id="FKD" /> Qty: <input type="text" name="FKDQ" id="FKDQ" /><br />
Giant Fountain: $39.95 ea. <input type="checkbox" name="GF" id="GF" /> Qty: <input type="text" name="GFQ" id="GFQ" /><br />
Shipment Method:
<select id="Ship" name="Ship">
<option value="4.95">Standard $4.95</option>
<option value="8.95">Express $8.95</option>
<option value="12.95">Next Day $12.95</option>
</select><br />
<input onClick="return Verify()" name="submit" id="submit" type="submit" value="Submit" /><input type="reset" value="Reset" onClick="ResetF();" /><input name="price" id="price" type="button" value="Price Check" onClick="priceC();" />
</body>
</html>
Please and Thank You
Alex