Se il test non e` verificato invia il modulo una volta sola, altrimenti lo invia due volte, con quello script.
Il test va chiamato all'evento onsubmit del form
E NON VA FATTO PARTIRE IL FORM DALLA FUNZIONE:
codice:
<form action="#" method="post" id="annuncio" onsubmit="Modulo('modulo_edit_prodotto_2.asp');">
<fieldset>
<legend>Nuovo Immobile:</legend>
<label for="immobile">Immobile: </label>
<input name="immobile" type="text" id="immobile" value="" size="20" /></p>
<input type="submit" name="Submit" value="Invia" /></p>
</fieldset>
</form>
Il JS:
codice:
function Modulo(destinazione) {
var Immobile = document.getElementById('annuncio').immobile;
if ((Immobile == "") || (Immobile == "undefined")) {
alert("Il campo Immobile non è Valido.");
document.getElementById('annuncio').immobile.focus();
return false;
} else {
document.getElementById('annuncio').action = destinazione;
return true;
}
}