La filosofia di questo post e'
Sto cercando di richiamare una funzione di controllo dentro un'altra funzione. La cosa "funziona", ma resetta i valori dei campi, cosa che vorrei evitare.
codice:
function Quick(){
if(Controlla() == false){
document.euroform.action = "action.asp;
document.euroform.target = "_top";
document.euroform.submit();
}
}
codice:
function Controlla(){
var campo;
var titolo=document.euroform.titolo.value;
var testo=document.euroform.testo.value;
var errore='';
if (titolo==''){
errore=errore+'Titolo\n';
campo=document.euroform.titolo;
}
if (testo==''){
errore=errore+'Testo\n';
if (!campo) campo=document.euroform.testo;
}
// -----------------------------------------
// stringa per controllo
// -----------------------------------------
if (errore!=''){
alert('Devi compilare\n'+errore);
campo.focus();
return true;
}
}
Cos'e' che sbaglio???