I have some javascript that works perfectly with no errors but when i tried adding a new function i got this error message
[QUOTE]
Error: Expected ;
The function that is causing the problem is this
[CODE]function checkQuickSearch()
{
//var jobs = document.QuickSearch.job.options;
//var chosenjob = jobs[jobs.selectedIndex].value;
// var loc = document.QuickSearch.loc.options;
//var chosenloc = loc[loc.selectedIndex].value;
if(chosenjob==”default”)
{
alert(“Please select a job type”);
return false;
}else if(chosenloc=”default”)
{
alert(“Please select a location”);
return false;
}else
{
alert(“Well done…..validation passed”);
return true;
}
}
I won’t include the whole JS but just the functions that are getting called by the handlers
[CODE]window.onload = handlers;
——————————————————————–
// Function to register event handlers
function handlers()
{
document.addressForm.onsubmit = checkEmail;
document.QuickSearch.send.onsubmit checkQuickSearch;
attachFormHandlers()
}
——————————————————————
function checkEmail()
{
// Regular Expression for Phone Number
var regex=/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+.)+[a-zA-Z0-9.-]{2,4}$/;
// Test input
if(regex.test(document.addressForm.email.value))
{
// If good then allow form to submit
return true;
}else{
//If bad then warn user and block submission
alert(“Please enter a valid email address.”);
return false;
}
}
function checkQuickSearch()
{
//var jobs = document.QuickSearch.job.options;
//var chosenjob = jobs[jobs.selectedIndex].value;
// var loc = document.QuickSearch.loc.options;
//var chosenloc = loc[loc.selectedIndex].value;
if(chosenjob==”default”)
{
alert(“Please select a job type”);
return false;
}else if(chosenloc=”default”)
{
alert(“Please select a location”);
return false;
}else
{
alert(“Well done…..validation passed”);
return true;
}
}
//——————————————————————
function attachFormHandlers()
{
var form = document.getElementById(‘form1’) // get the form
if (document.getElementsByTagName)//make sure were on a newer browser
{
var objInput = document.getElementsByTagName(‘input’); // store all input fields
for (var iCounter=0; iCounter<objInput.length; iCounter++)
objInput[iCounter].onchange = function(){return attach(this);} //attach the onchange to each input field
}
form.onsubmit = function(){return validate();} //attach validate() to the form
}
What i want to do is get the value from the select box and if it says default, then display an error message…i thought it would be simple ?