Guten Tag.
Ich halte es für sinnvoller, nach folgenden Schema vorzugehen.
Code:
<html>
<head>
<title>JavaScript Übung Felix Rade CMD803</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function checkform() {
var errorText = "";
var sendForm = true;
var PLZ = true;
var radio = true;
var badwords = new Array ("asdf","Donald Duck", . . . schnipp . . . );
if (document.Formular.formName.value == "") {
errorText += "Bitte geben Sie einen Namen ein !\n";
sendForm = false;
}
else {
for (i=0;i<badwords.length;i++) {
if (document.Formular.formName.value == badwords[i]) {
errorText += "Die Eingabe '" + badwords[i] + "' ist nicht erlaubt !\n";
sendForm = false;
}
}
}
. . . schnipp . . .
}
if (sendForm == true) {
return true;
}
else{
alert(errorText);
return false;
}
}
//-->
</script>
</head>
<body bgcolor="#999999">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td width="30%" bordercolor="#FFFFFF">
<h3 align="left"> </h3>
</td>
<td width="70%" bordercolor="#FFFFFF">
<form action="nextsite.htm" method="post" name="Formular" id="Formular" onsubmit="return checkform()">
. . . schnipp . . .
<input type="submit" value="Und ab!" name="button" id="button">
</form>
</td>
</tr>
<tr>
<td bordercolor="#FFFFFF"> </td>
<td bordercolor="#FFFFFF"> </td>
</tr>
</table>
</body>
</html>
Ist aber nur ein Vorschlag.
Beste Grüße . . . Karsten