Formular Problem

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • Formular Problem

    Hallo,
    ich habe gerade ein Formular erstellt und es mit JavaScript etwas vereinfacht.
    Einfach mal der Code ich denke das is am einfachstem:

    Quellcode

    1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    3. <html xmlns="http://www.w3.org/1999/xhtml">
    4. <head>
    5. <title>Titel</title>
    6. <script type="text/javascript" src="form.js"></script>
    7. </head>
    8. <body>
    9. <form action="index.php" method="post" name="Formular" onsubmit="return chkFormular()"><br />
    10. <tr><th>Name</th><th><input type="text" name="name"></th></tr>
    11. <tr><th>E-Mail-Adresse</th><th><input type="text" name="email"></th></tr>
    12. <tr><th>Homepage/Forum<br/><small>falls vorhanden</small></th><th><input type="text" name="home"></th></tr>
    13. <tr><th>Bestellung</th><th><select name="sel" onChange="process()"><option></option><option>Teamspeak 2 Server</option><option>Teamspeak 3 Server</option><option>Teamspeak 2 Channel</option><option>Teamspeak 2 Bot</option><option>Teamspeak 3 Channel</option><option>Voiceserver</option></th></tr>
    14. </table>
    15. <div id="myDivElement" />
    16. </body>
    17. </html>
    Alles anzeigen


    Quellcode

    1. function process()
    2. {
    3. if (document.Formular.sel.value == "Teamspeak 2 Server") {
    4. var string
    5. string = '<table><tr>'
    6. + '<th>Teamspeak Name</th><th><input type="text" name="tsname"></th>'
    7. + '</tr>'
    8. + '<tr>'
    9. + '<th>Teamspeak Passwort</th><th><input type="text name="tspw"></th>'
    10. + '</tr>'
    11. + '<tr>'
    12. + '<th>Slots</th><th><select name="slots"><option>10</option><option>30</option><option>50</option><option>70</option><option>100</option></th>'
    13. + '</tr>'
    14. + '<tr>'
    15. + '<th>Wunschport</th><th><input type="text" name="port"></th>'
    16. + '</tr><tr><th>Sonstige Anmerkungen</th><th><textarea name="sonstig" cols="20" rows="10"></textarea></th>'
    17. + '</tr><tr><th><input type="submit" value="Absenden"></th><th><input type="reset" value="Abbrechen"></th>'
    18. + '</tr></table>'
    19. myDiv = document.getElementById("myDivElement");
    20. myDiv.innerHTML = string;
    21. }
    22. }
    23. function chkFormular()
    24. {
    25. if (document.Formular.name.value == "") {
    26. alert("Bitte Ihren Namen eingeben!");
    27. document.Formular.name.focus();
    28. return false;
    29. }
    30. }
    Alles anzeigen


    Kleine Erklärung:
    Das Formular soll je nach der Entscheidung des Pakets im Select-Field sel validiert werden. Dies passiert durch den Eventhandler onChange und der Funktion process().

    Theoretisch sollte, wenn der Feld Name falsch ist ein Fenster aufgehen indem der Client darauf hingewiesen wird.
    Leider ist dies nicht der Fall und ich frage mich einfach warum. Ich habe schon alles versucht aber ich finde einfach keine Lösung. Ich hoffe jemand in diesem Forum kann mir hier weiterhelfen.