
var cap;
function loadcap() {
  cap = Math.round(1000000 * Math.random());
  var captchatext = document.getElementById("cap");
  captchatext.innerText = captchatext.textContent = cap ;//+ " Please Enter This Number In Security Box Below ";
  document.form1.cap2.value = cap;
}
 
var numRE = /^[0-9()+\-\ ]+$/;
var alphaRE = /^[a-zA-Z0-9\-\ ]+$/;
var letters = /^[a-zA-Z\-\ ]+$/;
var emailRE = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
var userRE14 = new RegExp("(ftp|http:\/\/|https:\/\/|www.)");
 
function trim(str)
{
   return str.replace(/^\s+|\s+$/g,'');
}

function form_validation(theForm) {
 
  if (!letters.test(theForm['voornaam'].value)) {
    alert("Voornaam is verplicht, moet alleen uit [A-Z] letters bestaan.");
    theForm['voornaam'].focus(); 
    return false
  }
  if (!letters.test(theForm['achternaam'].value)) {
    alert("Achternaam is verplicht, moet alleen uit [A-Z] letters bestaan.");
    theForm['achternaam'].focus(); 
    return false
  }
  if (theForm['provincie'].value != "") {
	  if (!letters.test(theForm['provincie'].value)) {
		alert("Provincie , moet alleen uit [A-Z] letters bestaan.");
		theForm['provincie'].focus(); 
		return false
	  }
  }
   if (theForm['land'].value != "")
  if (!letters.test(theForm['land'].value)) {
    alert("Land , moet alleen uit [A-Z] letters bestaan.");
    theForm['land'].focus(); 
    return false
  }
 
  
  if (!numRE.test(theForm['phone'].value)) {
    alert("Telefoon is verplicht, moet alleen uit nummers  en [ ()+ - ] bestaan.");
    theForm['phone'].focus(); 
    return false
  }
  if (theForm['fax'].value != "") {
    if (!numRE.test(theForm['fax'].value)){
      alert("Fax nummer, moet alleen uit nummers  en [ ()+ - ] bestaan.");
      theForm['fax'].focus(); 
      return false
    }
  }
  
  
   if (theForm['company'].value != "") {
    if (!letters.test(theForm['company'].value)){
      alert("Bedrijf, moet alleen uit [A-Z] letters bestaan.");
      theForm['fax'].focus(); 
      return false
    }
  }
 
  if (!emailRE.test(theForm['email'].value)) {
    alert("Geldig e-mail adres is verplicht");
    theForm['email'].focus(); 
    return false
  }
  
 if (theForm['opmerkingen'].value == "") {
  if (userRE14.test(theForm['opmerkingen'].value)) {
    alert("Aanvullende informatie mag geen URL's bevatten [ http://www.etc.com ]");
    theForm['opmerkingen'].focus(); 
    return false
  }
   alert("AUB Opmerkingen Verplicht!");
   theForm['opmerkingen'].focus(); 
    return false
 }
 
  if (theForm['captcha'].value!=cap){
    alert("Geef de juiste waarde in Veiligheid-code Tekstvak");
    theForm['captcha'].focus(); 
    return false
  }
 
   return true; // allow submit
}
 
