codice:
on (press, keyPress "<Enter>") {
risultato = "";
asnome = "";
ascognome = "";
associeta = "";
asindirizzo = "";
astelefono = "";
ascellulare = "";
asemail = "";
asmessaggio = "";
}
on (release, keyPress "<Enter>") {
errori = new Array('Inserire il nome.', 'Inserire il cognome.', 'Inserire il nome della società.', 'Inserire l\'indirizzo.', 'Inserire il numero di telefono.', 'Indirizzo e-mail non valido.', "Inserire testo dell'e-mail.");
err = 0;
count = 0;
errore = false;
if (nome == "" || nome == undefined) {
errore = true;
err = 0;
asnome = "*";
} if (!errore) {
if (cognome == "" || cognome == undefined) {
errore = true;
err = 1;
ascognome = "*";
}
} if (!errore) {
if (societa == "" || societa == undefined) {
errore = true;
err = 2;
associeta = "*";
}
} if (!errore) {
if (indirizzo == "" || indirizzo == undefined) {
errore = true;
err = 3;
asindirizzo = "*";
}
} if (!errore) {
if (telefono == "" || telefono == undefined) {
errore = true;
err = 4;
astelefono = "*";
}
}
if (!errore) {
caratteri = new Array('1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '.', '_', '@');
for (var i = 0; i<caratteri.length; i++) {
if (mail.indexOf(caratteri[i]) == -1) {
errore = true;
err = 5;
asemail = "*";
}
}
}
if (!errore) {
for (i=0; i<email.length; i++) {
if (email.charAt(i) == "@") {
count++;
}
}
if (count != 1) {
errore = true;
err = 5;
asemail = "*";
}
}
if (!errore) {
dividi = email.split("@");
if (dividi[0].length<1) {
errore = true;
err = 5;
asemail = "*";
}
if (dividi[1].indexOf(".")<0) {
errore = true;
err = 5;
asemail = "*";
} else {
dominio = dividi[1].split(".");
if (dominio[0].length<2) {
errore = true;
err = 5;
asemail = "*";
}
if (dominio[1].length<2) {
errore = true;
err = 5;
asemail = "*";
}
}
}
if (!errore) {
if (messaggio == "" || messaggio == undefined) {
errore = true;
err = 6;
}
}
out = "";
if (!errore) {
loadVariables("form.php", "POST");
out = "Messaggio inviato correttamente!";
} else {
out = "";
out = errori[err];
}
}
Ho inserito un asterisco come errore su ogni campo inesatto(as+nomecampo è il nome delle variabili).