//function per validare le date
//elem: casella di testo,es: document.form.text
//lang: lingua per i messaggi,lingue supportate it,en,es
function checkDate(elem,lang){
  
  if(lang=="it"){
    var msg1="Inserire data in formato gg/mm/aaaa";
    var msg2="Impossibile utilizzare un valore superiore a 31 per i giorni";
    var msg3="Impossibile utilizzare un valore superiore a 12 per i mesi";
    var msg4="Impossibile utilizzare un valore inferiore a 1900 per l'anno";
  }
  else if(lang=="es"){
    var msg1="";
    var msg2="";
    var msg3="";
    var msg4="";
  }
  else {
    var msg1="Insert date with format gg/mm/aaaa";
    var msg2="Impossible to use a advanced value to 31 for the days";
    var msg3="Impossible to use a advanced value to 12 for the months";
    var msg4="Impossible to use an inferior value to 1900 for the year";
  }
  var v = elem;
  if (v.value.length > 10 || v.value=="" || v.value.substring(2,3) != "/" ||
      v.value.substring(5,6) != "/" ||
      isNaN(v.value.substring(0,2)) ||
      isNaN(v.value.substring(3,5)) ||
      isNaN(v.value.substring(6,10))) {
    alert(msg1);
    v.value = "";
    v.focus();
    //return false;
  } else if (v.value.substring(0,2) > 31) {
    alert(msg2);
    //v.select();
    v.value = "";
    //return false;
  } else if (v.value.substring(3,5) > 12) {
    alert(msg3);
    v.value = "";
    v.focus();
    //return false;
  } else if (v.value.substring(6,10) < 1900) {
    alert(msg4);
    v.value = "";
    v.focus();
    //return false;
  } 
}

