// JavaScript Document
// Javascript validation functions
// http://www.designplace.org/

//function to check empty fields

function isEmpty(strfield1, strfield2, strfield3, strfield4, strfield5, strfield6) {


//change "field1, field2 and field3" to your field names
strfield1 = document.customerinfo.companyname.value 
strfield2 = document.customerinfo.address.value
strfield3 = document.customerinfo.pc.value
strfield4 = document.customerinfo.place.value
strfield5 = document.customerinfo.phone.value
strfield6 = document.customerinfo.contact.value
strfield7 = document.customerinfo.email.value

  //name field
    if (strfield1 == "" || strfield1 == null || !isNaN(strfield1) || strfield1.charAt(0) == ' ')
    {
    alert("Vul a.u.b. de bedrijfsnaam in")
    return false;
    }


    if (strfield2 == "" || strfield2 == null || !isNaN(strfield2) || strfield2.charAt(0) == ' ')
    {
    alert("Vul a.u.b. uw adres in")
    return false;
    }

    if (strfield3 == "" || strfield3 == null || !isNaN(strfield3) || strfield3.charAt(0) == ' ')
    {
    alert("Vul a.u.b. uw postcode in")
    return false;
    }

    if (strfield4 == "" || strfield4 == null || !isNaN(strfield4) || strfield4.charAt(0) == ' ')
    {
    alert("Vul a.u.b. een plaats in")
    return false;
    }

    if (strfield5 == "" || strfield5 == null || strfield5.charAt(0) == ' ')
    {
    alert("Vul a.u.b. uw telefoonnummer in")
    return false;
    }

    if (strfield6 == "" || strfield6 == null || !isNaN(strfield6) || strfield6.charAt(0) == ' ')
    {
    alert("Vul a.u.b. uw contactpersoon in\nIndien u deze niet hebt dan kunt u uw naam nogmaals invullen.");
    return false;
    }
    return true;


    if (strfield7 == "" || strfield7 == null || !isNaN(strfield7) || strfield7.charAt(0) == ' ')
    {
    alert("Vul a.u.b. uw emailadres in");
    return false;
    }
    return true;
}



//function to check valid email address
function isValidEmail(strEmail){
  validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
  strEmail = document.customerinfo.email.value;

   // search email text for regular exp matches
    if (strEmail.search(validRegExp) == -1) 
   {
      alert('Wijzig het mailadres in een geldig mailadres a.u.b.');
      return false;
    } 
    return true; 
}


//function that performs all functions, defined in the onsubmit event handler

function check(form)
	{
	if (isEmpty(form.field1))
		{
		if (isEmpty(form.field2))
			{
			if (isEmpty(form.field3))
				{
				if (isEmpty(form.field4))
					{
					if (isEmpty(form.field5))	
						{
						if (isEmpty(form.field6))
							{
							if (isEmpty(form.field7))
								{
								if (isValidEmail(form.field7))
									{
									return true;
									}
	  							}
 							}
						}
					}
				}
			}
		}
	return false;
	}

