
// non-empty textbox

function isEmpty(strng, vCampo) {
var error = "";
  if (strng.length == 0) {
     error = "Campo obrigatório não preenchido - " + vCampo + ".\n";
  }
return error;	  
}


// email

function checkEmail(strng) {
  var error="";
  if (strng.length == 0) {
   error = "Não inseriu o e-mail.\n";
  }

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "Favor inserir um e-mail correcto.\n";
    }
    else {
	//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "O e-mail tem caracteres incorrectos.\n";
         }
    }
  return error;    
}


// phone number - strip out delimiters and check for 10 digits

function checkPhone (strng) {
var error = "";
if (strng.length == 0) {
   error = "Não inseriu o nº de telefone.\n";
}

var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
    if (isNaN(parseInt(stripped))) {
       error = "O telefone tem caracteres incorrectos.";
  
    }
return error;
}



