Per controllare gli indirizzi Email puoi usare una regular Expression tipo questa:
http://xyfer.blogspot.com/2005/01/ja...validator.html
L'ultima controlla praticamente tutti gli indirizzi email.
Poi fai una funzione:
codice:
function checkEmail(form){
var obbligatorio = form.DESTINATARIO_1.value;
if(!obbligatorio || !reg.test(obbligatorio)){
alert("È necessario che almeno il primo campo sia un indirizzo Email valido");
return false;
}
var other = form.DESTINATARIO_2.value;
if(other){
if(!reg.test(other)){
alert("Il campo 2 deve essere un indirizzo Email valido o vuoto");
return false;
}
}
other = form.DESTINATARIO_3.value;
if(other){
if(!reg.test(other)){
alert("Il campo 3 deve essere un indirizzo Email valido o vuoto");
return false;
}
}
other = form.DESTINATARIO_4.value;
if(other){
if(!reg.test(other)){
alert("Il campo 4 deve essere un indirizzo Email valido o vuoto");
return false;
}
}
other = form.DESTINATARIO_5.value;
if(other){
if(!reg.test(other)){
alert("Il campo 5 deve essere un indirizzo Email valido o vuoto");
return false;
}
}
other = form.DESTINATARIO_6.value;
if(other){
if(!reg.test(other)){
alert("Il campo 6 deve essere un indirizzo Email valido o vuoto");
return false;
}
}
return true;
}
e l'associ all'evento onsubmit della form:
codice:
<form name="myform" method="POST" ACTION="processadati.asp" onsubmit="return checkEmail(this);">
Questo è sufficiente affinché non ti invii la form se i tuoi requisiti non sono soddisfatti