scusa hai ragione....riscrivo tutto il codice...
chiamo la funzione al click del bottone:
<input type="button" value= "Inserisci" name= "invia" onclick="controllocampi('condominio','nome:indiriz zo')">
function controllocampi(nomeform,ID,data)
{//per richiamare questa funzione occorre scrivere -controllocampi2('modulo','nome:cognome:indirizzo:' ,'emailtext')-
var IE4 = (document.all && !document.getElementById) ? true : false;
var NS4 = (document.layers) ? true : false;
var IE5 = (document.all && document.getElementById) ? true : false;
var N6 = (document.getElementById && !document.all) ? true : false;
ID1 = ID.split(":")
var q = ID1.length
for (var x=1; x <= q ;x++)
{
var input_1 = document.getElementById(ID1[x-1]).value
var nomecampo=document.getElementById(ID1[x-1]).name
if ((input_1 == "") || (input_1== "undefined"))
{
if (nomecampo == "corpo")
{ alert("Il campo Testo è obbligatorio")}
else{
alert("Il campo "+nomecampo+" è obbligatorio.");}
document.getElementById(ID1[x-1]).focus();
return false;
}
}
if (data == "")
{
alert("Il campo data è obbligatorio" )
return false;
}
else
{
if (data!='data'){
ris=validateUSDate(data)
if (ris==false)
{
alert("Scrivi la data nella forma corretta:gg/mm/aaaa")
return false;
}
}
}
document.getElementById(nomeform).submit();
}
function validateUSDate( strValue ) {
var objRegExp = /^\d{1,2}(\/)\d{1,2}\1\d{4}$/
if(!objRegExp.test(strValue))
return false; //formato data sbagliata
else{
var strSeparator = strValue.substring(2,3) //trova il separatore data
var arrayDate = strValue.split(strSeparator); //split date in giorno, mese, anno
var arrayLookup = { '01' : 31,'03' : 31, '04' : 30,'05' : 31,'06' : 30,'07' : 31,
'08' : 31,'09' : 30, '10' : 31,'11' : 30,'12' : 31}
var intDay=arrayDate[0];//intDay = parseInt(arrayDate[0]); //giorno arraydate[0];mese arraydate[1];anno arraydate[2];
//controlla che il valore del giorno sia concorde a quello del mese
if(arrayLookup[arrayDate[1]] != null) {
if(intDay <= arrayLookup[arrayDate[1]] && intDay != 0)
return true; //data corretta
}
//controlla Febbraio
var intYear = parseInt(arrayDate[2]);
var intMonth = parseInt(arrayDate[1]);
if( ((intYear % 4 == 0 && intDay <= 29 && intMonth == 2) || (intYear % 4 != 0 && intDay <=28 && intMonth==2)) && intDay !=0)
return true; //Feb. ha un numero valido di giorni
}
return false; //data errata
}
ok...ok....sempre brutto il codice,,,ma sigh...tu pensi sia ID scritto così?
in explorer funziona....ma significa ben poco....
grz