

function CheckEmpty(FieldName, FieldValue){
  if (FieldValue == '') {
     alert('Please enter ' + FieldName);
     return(true);}
  else
     {return(false)};
}

function LandisNL(FieldValue) {
  if (FieldValue =="NLD") {
    return true; 
  } else {
    return false; 
  }
} 

function FormValidate(theform){
     if (CheckEmpty('Company name', theform.Bedrijfsnaam.value) == true){
        theform.Bedrijfsnaam.focus();
        return(false);
     }
     if (CheckEmpty('Name', theform.Contactpersoon.value) == true){
        theform.Contactpersoon.focus();
        return(false);
     }

     if (theform.Emailadres.value.indexOf("@")==-1 ||
        theform.Emailadres.value.indexOf(".")==-1 ||
  	    theform.Emailadres.value.indexOf(" ")!=-1 ||
	    theform.Emailadres.value.length<6)
     {
       alert("Invalid email address, please enter a valid email address");
       theform.Emailadres.focus();
	   return(false);
     }
 return true;
}

function ValidateNewCustomer(theform){
     if (CheckEmpty('Company name', theform.Bedrijfsnaam.value) == true){
        theform.Bedrijfsnaam.focus();
        return(false);
     }
     if (CheckEmpty('Address', theform.Adres.value) == true){
        theform.Adres.focus();
        return(false);
     }
     if (CheckEmpty('Postcode', theform.Postcode.value) == true){
        theform.Postcode.focus();
        return(false);
     }
     if (CheckEmpty('Place', theform.Plaats.value) == true){
        theform.Plaats.focus();
        return(false);
     }
     if (CheckEmpty('Country', theform.Land.value) == true){
        theform.Land.focus();
        return(false);
     }
     if (CheckEmpty('Telephone', theform.Telefoon.value) == true){
        theform.Telefoon.focus();
        return(false);
     }
     if (LandisNL(theform.Land.value) && (CheckEmpty('K.v.K', theform.KVK.value) == true)){
        theform.KVK.focus();
        return(false);
     }
     if (CheckEmpty('VAT Number', theform.BTWnummer.value) == true){
        theform.BTWnummer.focus();
        return(false);
     }
     
     if (CheckEmpty('Name', theform.Contactpersoon.value) == true){
        theform.Contactpersoon.focus();
        return(false);
     }

     if (theform.Emailadres.value.indexOf("@")==-1 ||
        theform.Emailadres.value.indexOf(".")==-1 ||
  	    theform.Emailadres.value.indexOf(" ")!=-1 ||
	    theform.Emailadres.value.length<6)
     {
       alert("Invalid email address, please enter a valid email address");
       theform.Emailadres.focus();
	   return(false);
     }
 return true;
}