Code: Alles auswählen
<script language="javascript" type="text/javascript">
function chkRegister ()
{
if (document.register.pass1.value=='')
{
document.getElementById('error').innerHTML='<center><TABLE bgcolor="#8e0000" bordercolor="#bf0000" border="1px"><TR><TD style="border:0px"><P style="color:#ffffff; text-align: center; margin-left:10px; margin-right:10px">Das Feld ist leer</P></TD></TR></TABLE></center>';
document.register.pass1.focus();
return false;
};
if (document.register.pass2.value=='')
{
document.getElementById('error').innerHTML='<center><TABLE bgcolor="#8e0000" bordercolor="#bf0000" border="1px"><TR><TD style="border:0px"><P style="color:#ffffff; text-align: center; margin-left:10px; margin-right:10px">Das Feld ist leer</P></TD></TR></TABLE></center>';
document.register.pass2.focus();
return false;
};
if (document.register.pass1.value!=document.getElementById('pass2').value)
{
document.getElementById('error').innerHTML='<center><TABLE bgcolor="#8e0000" bordercolor="#bf0000" border="1px"><TR><TD style="border:0px"><P style="color:#ffffff; text-align: center; margin-left:10px; margin-right:10px">Die beiden Passworte stimmen nicht überein.</P></TD></TR></TABLE></center>';
document.register.pass1.value='';
document.register.pass2.value='';
document.register.pass1.focus();
return false;
}
if (document.register.name.value=='')
{
document.getElementById('error').innerHTML='<center><TABLE bgcolor="#8e0000" bordercolor="#bf0000" border="1px"><TR><TD style="border:0px"><P style="color:#ffffff; text-align: center; margin-left:10px; margin-right:10px">Das Feld ist leer</P></TD></TR></TABLE></center>';
document.register.name.focus();
return false;
}
if (document.register.email.value=='')
{
document.getElementById('error').innerHTML='<center><TABLE bgcolor="#8e0000" bordercolor="#bf0000" border="1px"><TR><TD style="border:0px"><P style="color:#ffffff; text-align: center; margin-left:10px; margin-right:10px">Das Feld ist leer</P></TD></TR></TABLE></center>';
document.register.email.focus();
return false;
}return register}
</script>
<center>
<div id="error"></div>
<table width="100%"><tr><td width="50%"><tr><td>
<h1><u>Registrierung</u></h1>
<form method="post" action="newAccount.php" onSubmit="return chkRegister;" name="register">
<p>Benutzername: <br /><input type="text" name="name" size="40" onfocus="clearInput ('name','Benutzername')" id="name" value="Benutzername"></p>
<p>Email-Addresse: <br /><input type="text" name="email" size="40" onfocus="clearInput ('regmail','Email-Adresse')" id="regmail" value="Email-Adresse"></p>
<p>Passwort: <br /><input type="password" name="pass1" size="40" onfocus="clearInput ('pass1','Passwort')" id="pass1" value="Passwort"></p>
<p>Wiederholen: <br /><input type="password" name="pass2" size="40" onfocus="clearInput ('pass2','Wiederholen')" id="pass2" value="Wiederholen"></p>
<input type="submit" name="submit" value="Registrieren">
</form>
PPS: Mit nicht funktionieren meine ich, der Browser leitet mich zu newAcc.php weiter, obwohl im Formular Fehler enthalten sind.
MfG Naums