function.js
codice:
//////////////////////////////////////////
// Controlla che il campo non sia vuoto //
//////////////////////////////////////////
function ctr_campovuoto(f,campo,msg){
document.f.campo.style.backgroundColor="white";
if (document.f.campo.value == ""){
document.f.campo.style.backgroundColor="red";
alert(msg);
document.f.campo.focus();
}
}
//////////////////////////////////////////
// Controlla che ci siano solo numeri //
//////////////////////////////////////////
function ctr_solonumeri(f,campo,msg){
document.f.campo.style.backgroundColor="white";
if (isNaN(document.f.campo.value)){
document.f.campo.style.backgroundColor="red";
alert(msg);
document.f.campo.focus();
}
}
registrazione.php
codice:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>NoiDelBds</title>
<script type="text/javascript" language="javascript" src="inc/function.js"></script>
</head>
<body>
Registrazione</p>
<form name="registrazione" action="registrazione.php?action=controllo" method="post" onsubmit="return controllo_totale(); ">
Nome: <input type="text" size="20" maxlength="15" name="nome" />
Cognome: <input type="text" size="20" maxlength="15" name="cognome" />
Username:* <input type="text" size="25" maxlength="20" name="username" onchange="return controllo_username();" />
L'username deve avere una lunghezza compresa tra i 5 e 20 caratteri.
Password:* <input type="password" size="25" maxlength="20" name="password" onchange="return ctr_solonumeri(registrazione,password,"Errore!La password può includere solo numeri!");" />
La Password deve avere una lunghezza compresa tra i 5 e 20 caratteri.
Conferma Password:* <input type="password" size="25" maxlength="20" name="conferma_password" />
Email:* <input type="text" size="25" maxlength="30" name="email" onchange="return convalida_email();" />
Non permettere agli altri utenti di vedere il mio indirizzo email: <input type="checkbox" name="email_visible" value="1" />
(* Campi Obbligatori)
Per completare la registrazione, vi verrà inviata un'email con le istruzioni al vostro indirizzo email.
<input name="registrami" type="submit" value="Registrami" />
<input name="action" type="hidden" value="controllo" />
</form>
</body>
</html>