Problem adding variables to a function in a form

Hi, firstly I apologise if the title of this thread isn’t quite accurate. I’m sure you’ve all heard it before but I am a complete newbie to Javascript so again: apologies if this is boring and tiresome to even read, let alone help with!

I have been asked to make some changes to a form that uses Javascript for the form validation. There is a ‘function’ that contains the variables of the various form fields and then further code to raise ‘alerts’ if one of the fields on the form hasn’t been filled in. My problem is that for some reason I am unable to add an extra variable to this code after the field of ‘County’ (this will hopefully make sense when you see the code / link…) and I am stumped as to why. I am able to add variables for all of the other required fields except for ‘Postcode’ after ‘County’. This is the case for both forms. The link is here: http://samdelara.co.uk/previews/banq…ation-form.htm and the code I am trying edit is below. The issues seems to be when I add && isPostcode() to this chunk of code:-

function checkAvailibility()
{
// re-calculate...
calculate ();
if ( isName() && isAddress1() && isTown() && isCounty() && isPostcode() && isTel() && isYourEmail() && isFuncDate() && somethingToQuoteFor() && isYourEmailValid() ) {
  document.ordersummary.emailQuote.value = "No";
  setValue();
 return true;
 }
 else
 {
 return false;
 }
}

/************* FULL CODE BELOW ******************/

function checkAvailibility()
{
// re-calculate...
calculate ();
if ( isName() && isAddress1() && isTown() && isCounty() && isPostcode() && isTel() && isYourEmail() && isFuncDate() && somethingToQuoteFor() && isYourEmailValid() ) {
  document.ordersummary.emailQuote.value = "No";
  setValue();
 return true;
 }
 else
 {
 return false;
 }
}


function isName() { if (document.ordersummary.Name.value=="") { alert ("\
 Please Enter Your Name")
document.ordersummary.Name.focus(); return false; } return true; }
function isAddress1() { if (document.ordersummary.Address1.value=="") { alert ("\
 Please Enter Your Address")
document.ordersummary.Address1.focus(); return false; } return true; }
function isTown() { if (document.ordersummary.Town.value=="") { alert ("\
 Please Enter Your Town")
document.ordersummary.Town.focus(); return false; } return true; }
function isCounty() { if (document.ordersummary.County.value=="") { alert ("\
 Please Enter Your County")
document.ordersummary.County.focus(); return false; } return true; }
function isTel() { if (document.ordersummary.Tel.value=="") { alert ("\
 Please Enter Your Telephone Number")
document.ordersummary.Tel.focus(); return false; } return true; }
function isPostcode() { if (document.ordersummary.Postcode.value=="") { alert ("\
 Please Enter Your Postcode")
document.ordersummary.Postcode.focus(); return false; } return true; }
function isYourEmail() { if (document.ordersummary.YourEmail.value=="") { alert ("\
 Please Enter Your Email")
document.ordersummary.YourEmail.focus(); return false; } return true; }
function isFuncDate() { if (document.ordersummary.FuncDate.value=="") { alert ("\
 Please Enter Your Function Date")
document.ordersummary.FuncDate.focus(); return false; } return true; }
function isemailonly() { if (document.ordersummary.emailonly.value=="") { alert ("\
 Please Enter Your Email Address")
document.ordersummary.emailonly.focus(); return false; } return true; }

Any help would be massivley appreciated!!

File not found?

Strange…the forum seems to have not copied my link correctly. I have pasted it again:

Online Quotation - The Banqueting Hire Service

Online Quotation - The Banqueting Hire Service

How is your code from above being worked in to the already existing checkAvailability function?

Are you completely replacing that function, or are you trying to get them to co-exist in some manner?

Hi,

Sorry, the code you saw then was someone elses attempted solution. The original code I was given is below. I’m aware that the code is of poor quality but I’ve just been asked to do a quick fix and get the ‘alerts’ working for all of the fields higlighted in pink. The problem seems to arise when I add && isPostcode() to the function checkAvailibility() script…Instead of giving it an alert it just calls the sendquote.php file in a new window…

Do you have any idea how I can fix this?

function checkAvailibility()
{
// re-calculate…
calculate ();
if ( isName() && isAddress1() && isTown() && isCounty() && isPostcode() && isTel() && isYourEmail() && isFuncDate() && somethingToQuoteFor() && isYourEmailValid() ) {
document.ordersummary.emailQuote.value = “No”;
setValue();
return true;
}
else
{
return false;
}
}

function isName() { if (document.ordersummary.Name.value==“”) { alert ("
Please Enter Your Name")
document.ordersummary.Name.focus(); return false; } return true; }
function isAddress1() { if (document.ordersummary.Address1.value==“”) { alert ("
Please Enter Your Address")
document.ordersummary.Address1.focus(); return false; } return true; }
function isTown() { if (document.ordersummary.Town.value==“”) { alert ("
Please Enter Your Town")
document.ordersummary.Town.focus(); return false; } return true; }
function isCounty() { if (document.ordersummary.County.value==“”) { alert ("
Please Enter Your County")
document.ordersummary.County.focus(); return false; } return true; }
function isTel() { if (document.ordersummary.Tel.value==“”) { alert ("
Please Enter Your Telephone Number")
document.ordersummary.Tel.focus(); return false; } return true; }
function isPostcode() { if (document.ordersummary.Postcode.value==“”) { alert ("
Please Enter Your Postcode")
document.ordersummary.Postcode.focus(); return false; } return true; }
function isYourEmail() { if (document.ordersummary.YourEmail.value==“”) { alert ("
Please Enter Your Email")
document.ordersummary.YourEmail.focus(); return false; } return true; }
function isFuncDate() { if (document.ordersummary.FuncDate.value==“”) { alert ("
Please Enter Your Function Date")
document.ordersummary.FuncDate.focus(); return false; } return true; }
function isemailonly() { if (document.ordersummary.emailonly.value==“”) { alert ("
Please Enter Your Email Address")
document.ordersummary.emailonly.focus(); return false; } return true; }

Online Quotation - The Banqueting Hire Service

Sam