
function validate(form) 
{
    function isValidEmail(str) 
    {
        var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
        return(filter.test(str));
    }
    function isValidPhone(str)
    { 
        var filter = /^[0-9()-.+ ]{10,16}$/; 
        return(filter.test(str));
    }
    
    form.company.value = form.company.value.replace(/^\s+|\s+$/g, '');
    if((form.bid.value == '') || (form.bid.value == null)) 
    {
        alert('Please select a bid before submitting this form.');
        form.bid.focus();
        return false;
    }
    else if ((form.company.value == '') || (form.company.value == null)) 
    {
        alert('You must fill in the name of your business in order to submit this form.');
        form.company.focus();
        return false;
    }
    else if ((form.contact.value == '') || (form.contact.value == null)) 
    {    
        form.contact.value = form.contact.value.replace(/^\s+|\s+$/g, '');
        alert('You must include a contact person for your business in order to submit this form.');
        form.contact.focus();
        return false;
    }
    else if((form.street1.value == '') || (form.street1.value == null))
    {
        alert('You must fill in a street address for your business in order to submit this form.');
        form.street1.focus();
        return false;
    }
    else if((form.city.value == '') || (form.city.value == null))
    {
        alert('You must fill in a city location for your business in order to submit this form.');
        form.city.focus();
        return false;
    }
    else if((form.zip.value == '') || (form.zip.value == null))
    {
        alert('You must fill in a zip code for your business in order to submit this form.');
        form.zip.focus();
        return false;
    }
    else if((form.phone.value == '') || (form.phone.value == null)
        || (!isValidPhone(form.phone.value)))
    {
        alert('You must fill in a 10-digit business phone number in order to submit this form.');
        form.phone.focus();
        return false;
    }
    else if ((form.email.value == '') || (form.email.value == null) 
        || (!isValidEmail(form.email.value)))
    {
        alert('Your email entry is not a valid address - please check it.');
        form.email.focus();
        return false;
    }
    else if ((form.captchaResponse.value == '') || (form.captchaResponse.value == null))
    {
        alert('You must type in the text from the grey box, input is case sensitive.');
        form.captchaResponse.focus();
        return false;
    }
    else 
    { 
        //alert('All good!'); 
        return true;
    }
}
