Con la tua modifica, se non inserisco una data mi da l'allert è tutto ok.
Se invece inserisco una data antecedente a quella dell campo arrivo, mi da l'allert ma mi va cmq nella pagina successiva.
Ovviamente prima non avevo postato gli script, adesso gli ho messi, s ti va di darmi una mano te ne sono grato.
Ciao
codice:
<form action="result.asp" method="post" name="form1" target="Content" id="form1" onSubmit=" MM_validateForm('arrivo','','R','partenza','','R'); if (ControlloDate(this, 'arrivo', 'partenza', 'Arrivo', 'Partenza')) return document.MM_returnValue">
codice:
<script language="JavaScript" type="text/JavaScript">
function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+'\n'; }
} if (errors) alert('Occore inserire il campo:\n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
<!--
function ControlloDate(f, campodata1, campodata2, nomecampo1, nomecampo2) {
var data1=f.elements[campodata1].value;
var data2=f.elements[campodata2].value;
if (data1=="" || data2=="") return true;
var oggetto1=new Date(parseInt(data1.substr(6)), parseInt(data1.substr(3, 2),10), parseInt(data1.substr(0, 2)));
var oggetto2=new Date(parseInt(data2.substr(6)), parseInt(data2.substr(3, 2),10), parseInt(data2.substr(0, 2)));
if (oggetto2-oggetto1<0) {
alert("Attenzione, il valore del campo '"+nomecampo2+"' è antecedente quello del campo '"+nomecampo1+"'.");
f.elements[campodata2].focus();
return false;
}
return true;
}
//-->
</script>