Scusate ragazzi, questo sarebbe il mio primo script Javascript, tuttavia quando clicco sul bottone, i form si cancellano e la pagina si posta al top.codice:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://w3.org/1999/xhtml"> <head> <title>Form di registrazione eTakeAway!</title> <link rel = "stylesheet" type = "text/css" href = "css/styleReg.css" /> <script type="text/javascript"> <!-- function checkForms(){ var email = document.register.email.value; var emailConfirm = document.register.email.value var name = document.register.name.value; var surnome = document.register.surname.value; var password = document.register.password.value; var passwordConfirm = document.register.passwordConfirm.value; var condition = document.register.condition.value; var telephone = document.register.telephone.value; var cell = document.register.cell.value; var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/; if (email != email_reg_exp || emailConfirm != email_reg_exp || emailConfirm == "undefined" || emailConfirm == "" email == "undefined" || email == "") { alert("Indirizzo email non valido!"); document.modulo.email.select(); return false; } else if (email != emailConfirm) { alert("L'indirizzo email non coincide!"); document.modulo.email.focus(); return false; } else if (password.length < 6 || password.length > 20) { alert("La password deve essere di almeno 6 caratteri alfanumerici e di massimo 20!"); document.modulo.password.focus(); }else if (password != passwordConfirm) { alert("La password non coincide!"); document.modulo.passwordConfirm.value = ""; document.modulo.passwordConfirm.focus(); return false; } else if (name == "" || name == "undefined") { alert("L'inserire nome!"); document.modulo.name.focus(); return false; } else if (surname == "" || surname == "undefined") { alert("L'inserire cognome!"); document.modulo.surname.focus(); return false; } else if (telephone == "" || telephone == "undefined") { alert("L'inserire recapito telefonico!"); document.modulo.telephone.focus(); return false; }else if (cell == "" || cell == "undefined") { alert("L'inserire recapito telefonico(cellulare)!"); document.modulo.cell.focus(); return false; }else if (condition == "" || condition == "undefined") { alert("DEVI ACCETTARE LE CONDIZIONI PER ISCRIVERTI!"); document.modulo.condition.focus(); return false; }else { document.modulo.action = "index.html"; document.modulo.submit(); } } //--> </script> </head> <body> <form id = "register" method = "post" onSubmit = "checkForms()"> <div > <label for = "email">Inserisci eMail di registrazione: </label> <div class="input-reg"><input id = "email" name = "email" type="text" /> </div></p> <label for = "emailConfirm">Conferma eMail: </label> <div class="input-reg"><input id = "emailConfirm" name = "emailConfirm" type="text" /> </div></p> <label for = "password">Scegli una Password: </label> <div class="input-reg"><input id = "password" name="password" type="password" /> </div></p> <label for = "passwordConfirm">Conferma Password: </label> <div class="input-reg"><input id = "passwordConfirm" name="passwordConfirm" type="password" /> </div> </p> <label for = "name">Nome: </label> <div class="input-reg"><input id = "name" name = "name" type="text" /> </div> </p> <label for = "surname">Cognome: </label> <div class="input-reg"><input id = "surname" name = "surname" type="text" /> </div></p> <label for = "telephone">Recapito telefonico: </label> <div class="input-reg"><input id = "telephone" name = "telephone" type="text" /> </div> </p> <label for = "cell">Recapito telefonico(cellulare): </label> <div class="input-reg"><input id = "cell" name = "cell" type="text" /> </div></p> <div> Dove sei venuto a conoscenza del nostro servizio web? </p> <label for = "howtosite">In un nosto punto vendita </label> <input id = "howtosite" name = "howtosite" value = "pvendita" type = "radio"> <label for = "howtosite">Pubblicita' </label> <input id = "howtosite" name = "howtosite" value = "publicity" type = "radio"> <label for = "howtosite">Nel Web </label> <input id = "howtosite" name = "howtosite" value = "web" type = "radio"> <label for = "howtosite">Da un amico </label> <input id = "howtosite" name = "howtosite" value = "friend" type = "radio"> <label for = "howtosite">Altro </label> <input id = "howtosite" name = "howtosite" value = "other" type = "radio"> </p> </div> <label for = "condition"> In base alla legge 675/96 sulla tutela dei dati personali autorizzo il trattamento degli stessi per finalita' informative e/o pubblicitarie all'azienda </label> <input id = "condition" name = "condition" value = "Accept" type = "checkbox"/> </div> <div><button type = "submit" id = "submit" value = "Register">Registrati</button> </div> </div> </form> </body> </html>
Come mai non funziona???Scusatemi, ma ci stò sbattendo la testa da ieri notte inutilmente!