io ho provato anche questo e non funge:
Codice PHP:
var elements = document.getElementsByTagName("input");
for (i=0; i < elements.length; i++) {
if(elements[i].getAttribute('name').substr(elements[i].getAttribute('name').length-3,3)=="_DT")
{
elements[i].onblur=function() {
this.style.borderColor='#000000';
this.style.backgroundColor='#FFFFFF';
valore=(this.value);
zx=elements[i];
formatta_valore = valore.replace(/\//g,""); // tolgo gli slash
controlla=valore.substr(1,7);
// alert(parseInt(formatta_valore.substr(1,7)));
if((parseInt(valore.substr(0,1)) < 3) && (parseInt(valore.substr(1,7)) == controlla)){
if(formatta_valore.length==8){
giorno=formatta_valore.substr(0,2);
mese=formatta_valore.substr(2,2);
anno=formatta_valore.substr(4,4);
this.value=giorno+"/"+mese+"/"+anno;
}
}
}
elements[i].onfocus=function() {
this.style.borderColor='#000000';
this.style.backgroundColor='#A1E2FF';
};
};
i++;
}
}
window.onload = formatta_dt;
mettendo gli alert, non appena var elements e' nullo il ciclo for termina!!!!