Hi all. :icon_smile:I am having problems with my form validation and getting it to run. I also have been unable to get the last page update to display at the bottom of the screen:icon_redface:. Is anyone able to help me to get these things to work - I am getting very frustrated with this:icon_cry:.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="author" content="Joanne Bujayer">
<title>All Produce at Joe's - Order Form</title>
<style type="text/css">
<!--
body,td,th {
font-family: Verdana, Arial, Helvetica, sans-serif;
color: #000000;
}
body {
background-color: #99FF99;
}
.style3 {color: #00FF00;
font-size: xx-large;
font-weight: bold;
}
-->
</style>
<!-- Ensure that mandatory fields of form have been completed I used a validation script -->
</head>
<script type="text/javascript">
//Used to check to see if any of the fields are empty that are necessary information.
onload = function validationComplete(Order)
{
if(emptyField(Order.Name))
alert("Please enter your name.");
else if(emptyField(Order.Address))
alert("Please enter your address.");
else if(emptyField(Order.Suburb))
alert("Please enter your suburb or town.");
else if(emptyField(Order.State))
alert("Please enter your state.");
else if(emptyField(Order.Postcode))
alert("Please enter your postcode.");
else if(emptyField(Order.Homeph))
alert("Please enter your home phone number.");
else if(emptyField(Order.CCNumber))
alert("Please enter your Credit Card number.");
else if(emptyField(Order.Type))
alert("Please enter your Credit Card type.");
else if(emptyField(Order.Expiry))
alert("Please enter your Credit Card expiry month.");
else if(emptyField(Order.Year))
alert("Please enter your Credit Card expiry year.");
else if(emptyField(Order.Basket))
alert("Please enter your basket choice.");
else if(emptyField(Order.Quantity))
alert("Please enter your basket quantity.");
else if(emptyField(Order.Street))
alert("Please enter your delivery street.");
else if(emptyField(Order.Town))
alert("Please enter your delivery town or suburb.");
else if(emptyField(Order.Pcode))
alert("Please enter your delivery postcode.");
else if(emptyField(Order.Ddr))
alert("Please enter your delivery date.");
else if(emptyField(Order.month))
alert("Please enter your delivery date.");
else if(emptyField(Order.yr))
alert("Please enter your delivery date.");
else if(emptyField(Order.Yes.value))
alert("Please enter your card message.");
else return true;
return false;
}
//Check to see if field is empty.
onload = function emptyField(Order)
{
if(textObj.value.length == 0) return true;
for (var i=0; i<textObj.value.length; ++i)
{
var ch = text.Obj.value.charAt(i);
if ch != ' ' && ch != '/t') return false;
}
return true;
}
//Validate shipping policy - don't ship on weekends. Make sure date is not in past or current date.
onload = function shipping(Order)
{
var deliverydate = calDdr(Order);
var day = Ddr.getDay();
var currentDate = new Date()
if(Ddr.getTime() < currentDate.getTime()) {
alert("Error: Delivery date must be future date.")
Orders.Ddr.focus()
Orders.Ddr.select()
return false;
}
if (day == 0) {
alert("Sorry we cannot delivery on Sunday.")
Orders.Ddr.focus()
Orders.Ddr.select()
return false;
}
if (day == 6) {
alert("Sorry we cannot delivery on Saturday.")
Orders.Ddr.focus()
Orders.Ddr.select()
return false;
}
else return true;
}
//This function validates a credit card entry to make sure that the number is correct.
onload = function isCreditCard(Order)
{
var CCNumber;
var odd = 1;
var even = 2;
var calcCard = 0;
var calcs = 0;
var ccNum2 = ' ';
var cc;
var r;
CCNumber = text.Obj.value;
for(var i = 0; i !=CCNumber.length; i++)
{
aChar = CCNumber.substring(i,i+1);
if (aChar == ' - ') {
continue;
}
CCNum2 = CCNum2 + aChar;
}
cc = parseInt(CCNum2);
if (cc == 0) {
return false;
}
r = CCNumber.lenth / 2;
if CCNumber.length - (parseInt(r)*2) == 0) {
odd = 2;
even = 1:
}
for (var x = CCNumber.length - 1; x > 0; x - -)
{
r = x / 2;
if (r < 1) }
r++;
}
if(x - (parseInt(r) * 2) != 0) {
calcs - (parseInt(CCNumber.charAt(x - 1))) * odd;
}
else {
calcs = (parseInt(CCNumber.charAt(x - 1))) * even;
}
if(calcs >= 10) {
calcs = cals = 10 + 1;
}
calcCard = calCard + calcs;
}
calcs = 10 - )(calcCard % 10);
if calcs == 10) {
calcs = 0;
}
if calcs == (parseInt(CCNumber.charAt(CCNumber.length - 1)))) {
return true;
}
else {
return false;
}
}
//This function validates the email address
onload = function validEmail(Order)
invalidChars = "/:,;"
if (email ==" ") {
return false;
}
for (i=0; i<invalidChars.length;i++) {
badChar = invalidChars.chatAt(i)
if (email.indexOf(badChar,0) > -1) {
return false;
}
}
atPos = email.indexOf("@",1)
if (atPos == -1) {
return false;
}
}
periodPos = email.indexOf(".",atPos)
if (periodPos == -1) {
return false;
}
if (periodPos+3 > email.length) {
return false;
}
return true;
}
onload = function submitIt(Order) {
if (!validemail(Order.email.value))
alert("Invalid email address. Please enter the correct email address.")
order.email.focus()
order.email.select()
return false;
}
return true;
}
//Used to make sure that a radio burron is selected.
onload = function checkRadio(checkvalue) {
var error = "";
if (!(checkvalue)) {
error = "Please check a radio button.\n";
}
return error;
}
for (i=0, n=Order.radios.length; i<n; i++) {
if (Order.radios[i].checked) {
var checkvalue = Order.radios[i].value;
break;
}
why += checkRadio(checkvalue);
}
</script>
<body>
<table width="890" height="976" border="0">
<tr>
<td colspan="3"><div align="center" class="style3">All Produce at Joe's</div></td>
</tr>
<tr>
<td width="202"><img src="home.jpg" alt="Home" width="202" height="201" border="0"></td>
<td width="678" colspan="2" rowspan="4"><h2>Order form for Joe's Fruit Shop</h2>
<p> </p>
<p><strong>A * means you must fill in the details</strong></p>
<p><strong>Your details:</strong><br>
<!-- Below is the form for Joe's Produce. Basic fields with options added for state, credit card type and dates --> </p>
<form name="Order" method="post" action="">
<label>*Name
<input name="Name" type="text" id="Name">
</label>
<p>
<label>*Address
<input name="Address" type="text" id="Address">
</label>
</p>
<p>
<label>*Suburb or Town
<input name="Suburb or Town" type="text" id="Suburb">
</label>
<label>*State
<select name="State" id="State">
<option>ACT</option>
<option>NSW</option>
<option>NT</option>
<option selected>QLD</option>
<option>SA</option>
<option>TAS</option>
<option>VIC</option>
<option>WA</option>
</select>
*Postcode
<input name="Postcode" type="text" id="Postcode" size="5" maxlength="4">
</label>
</p>
<p>
<label>*Home phone
<input name="Home phone" type="text" id="Home" size="11" maxlength="10">
</label>
<label>Work phone
<input name="Work phone" type="text" id="Work" size="11" maxlength="10">
</label>
</p>
<p>
<label>Fax
<input name="Fax" type="text" id="Fax" size="11" maxlength="10">
</label>
<label>Email address
<input name="Email address" type="text" id="email">
</label>
</p>
<p><strong>Credit card details</strong></p>
<p>
<label>*Credit Card Number
<input name="CCNumber" type="text" id="CCNumber" size="16" maxlength="16">
</label>
</p>
<p>
<label>*Type
<select name="Type" id="Type">
<option selected>Mastercard</option>
<option>Visa</option>
<option>AMEX</option>
</select>
</label>
<label>*Expiry date
<select name="Expiry date" id="Expiry">
<option selected>January</option>
<option>February</option>
<option>March</option>
<option>April</option>
<option>May</option>
<option>June</option>
<option>July</option>
<option>August</option>
<option>September</option>
<option>October</option>
<option>November</option>
<option>December</option>
</select>
</label>
<label>
<select name="Year" id="Year">
<option selected>2009</option>
<option>2010</option>
<option>2011</option>
<option>2012</option>
<option>2013</option>
<option>2014</option>
<option>2015</option>
<option>2016</option>
<option>2017</option>
<option>2018</option>
<option>2019</option>
<option>2020</option>
</select>
</label>
</p>
<p><strong>Purchase details</strong></p>
<p>
<label>*Basket choice
<select name="Basket choice" id="Basket">
<option selected>1A</option>
<option>2B</option>
<option>3C</option>
<option>4D</option>
<option>5E</option>
<option>6F</option>
<option>7G</option>
<option>8H</option>
<option>9I</option>
</select>
</label>
<label>Quantity
<select name="Quantity" id="Quantity">
<option selected>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
</select>
</label>
</p>
<p><strong>*Deliver to</strong></p>
<p>
<label>
<input name="HomeAdd" type="radio" id="HomeAdd" value="radio" checked>
Home address</label>
<br>
<label>
<input type="radio" name="OtherAdd" value="radio" id="OtherAdd">
Other address</label>
<br>
<label>
<input name="Street" type="text" id="Street">
(Street)</label>
</p>
<p>
<label>
<input name="Suburb or Town2" type="text" id="Town">
(Suburb or Town)</label>
<label>
<select name="State2" id="State2">
<option>ACT</option>
<option>NSW</option>
<option>NT</option>
<option selected>QLD</option>
<option>SA</option>
<option>TAS</option>
<option>VIC</option>
<option>WA</option>
</select>
(State)</label>
<label>
<input name="Postcode2" type="text" id="Pcode" size="5" maxlength="4">
(Postcode)</label>
<br>
</p>
<p>
<label>*Date delivery required
<select name="Date delivery required" id="Ddr">
<option selected>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
</select>
</label>
<label>
<select name="month" id="month">
<option selected>January</option>
<option>February</option>
<option>March</option>
<option>April</option>
<option>May</option>
<option>June</option>
<option>July</option>
<option>August</option>
<option>September</option>
<option>October</option>
<option>November</option>
<option>December</option>
</select>
</label>
<label>
<select name="yr" id="yr">
<option selected>2009</option>
<option>2010</option>
<option>2011</option>
<option>2012</option>
<option>2013</option>
<option>2014</option>
<option>2015</option>
</select>
</label>
</p>
<p>Include a card:
<label>
<input name="Yes" type="checkbox" id="Yes" checked>
Yes</label>
</p>
<p>Personal message on card:
<label>
<textarea name="Message" id="Message" cols="45" rows="5">Enter your personal message here</textarea>
</label>
</p>
<p>Click on <strong>Submit</strong> when done; click on <strong>Clear Form</strong> to restart.</p>
<p>
<input name="Submit" type="submit" id="Submit" value="Submit">
<label>
<input type="reset" name="Reset" id="Reset" value="Clear Form">
</label></p>
</form> </td>
</tr>
<tr>
<td><a href="Produce.html"><img src="produce.jpg" alt="Produce" width="202" height="201" border="0"></a></td>
</tr>
<tr>
<td><a href="History.html"><img src="history.jpg" alt="History" width="202" height="201" border="0"></a></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<script type="text/javascript">
var months=new Array(13);
months[1]="January";
months[2]="February";
months[3]="March";
months[4]="April";
months[5]="May";
months[6]="June";
months[7]="July";
months[8]="August";
months[9]="September";
months[10]="October";
months[11]="November";
months[12]="December";
var time=new date();
var lmonth=months[time.getMonth() + 1];
var date=time.getdate();
var year=time.getYear();
if (year < 2000)
year = year + 1900;
document.write("<right>" + lmonth + " ");
document.write(date + ", " + year + "</right>");
</script>
</body>
</html>