function validateFormOnSubmit(theForm) {
var reason = "";

  
  

  reason += validateEmpty(theForm.name);
  reason += validateEmpty(theForm.lastname);
  reason += validateEmpty(theForm.emailaddress);
  reason += validateEmpty(theForm.question);
   reason += validateEmpty(theForm.CAPTCHA);



  
 

      
  if (reason != "") {
    alert("The highlighted fields are obligatory:\n" + reason);
    return false;
  }

  return true;
}

function validateEmpty(fld) {
    var error = "";
  
    if (fld.value.length == 0) {
        fld.style.background = '#CEE9F4'; 
        error = "\n"
    } else {
        fld.style.background = 'White';
    }
    return error;   
}


function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
} 


function validatename(fld) {
    var error = "";
  
    if (fld.value.length == 0) {
        fld.style.background = 'silver'; 
        error = "The required field has not been filled in.\n"
    } else {
        fld.style.background = 'White';
    }
    return error;   
}