Klobidop: PLZ überprüfen

Hallo,
wie überprüfe ich, ob ein user in einem forumlarfeld 5 zahlen eingeben hat und nicht weniger, ich möchte, das ein fenster aufkommt, wenn weniger als 5 zahlen eingegeben werden, in dem eine fehlermeldung steht??
hat jemand zufällig das script parat.

  1. hi

    am einfachsten fragst du einfach, ob der inhalt des feldes größer als 9999 ist, denn alles was größer ist ist automatisch fünfstellig.

    so long
    ole
    (8-)>

    1. Hallo!

      am einfachsten fragst du einfach, ob der inhalt des feldes größer als 9999 ist, denn alles was größer ist ist automatisch fünfstellig.

      ist denn 01325 > 9999?

      Grüße
      Andreas

      1. hi Andreas

        punkt für dich :)
        bin einfach überarbeitet und betriebsblind...

        so long
        ole
        (8-)>

        1. hi Andreas

          punkt für dich :)
          bin einfach überarbeitet und betriebsblind...

          so long
          ole
          (8-)>

          geht nicht, mäh

          <html><head><title>Test</title>
          <script language="javascrip">
          function chkFormular()
          var chkZ = 1;
             for(i=0;i<document.Formular.PLZ.value.length;++i)
               if(document.Formular.PLZ.value.charAt(i) < "0"
               || document.Formular.PLZ.value.charAt(i) > "9")
                 chkZ = -1;
             if(chkZ == -1)
             {
               alert("Ungültige Postleitzahl!");
               document.Formular.PLZ.focus();
               return false;
              }
          if(document.Formular.PLZ.value.length != 5)
              {
             alert document.Formular.PLZ.value + " ist keine fünfstellige PLZ.")
             return false;
           }
          </script>
          </head>

          <body><form name="Formular" action="suche4.php" onSubmit="return chkFormular()" method="post">
              <select name="Vertriebsl">
              <option value="Vertriebsl">Alle</option>
              <option value="Bau- und Gartencenter">Bau- und Gartencenter</option>
              <option value="Direkt">Direkt</option>
              <option value="Sky">Sky</option>
              <option value="Plaza">Plaza</option>
              <option value="SEH">SEH</option>
              <option value="Wandmaker">Wandmaker</option>
            </select>
          PLZ: <input type="text" name="PLZ" value="" maxlength="5" size="5" /><br />
          <input type="submit" name="submit_button" value="Suchen" />
          </body>
          </html>

          1. neues problem, wenn ich nicht auf senden gehe, sonder enter drücke, dann kommt die abfrage nicht

            hi Andreas

            punkt für dich :)
            bin einfach überarbeitet und betriebsblind...

            so long
            ole
            (8-)>
            geht nicht, mäh

            <html><head><title>Test</title>
            <script language="javascrip">
            function chkFormular()
            var chkZ = 1;
               for(i=0;i<document.Formular.PLZ.value.length;++i)
                 if(document.Formular.PLZ.value.charAt(i) < "0"
                 || document.Formular.PLZ.value.charAt(i) > "9")
                   chkZ = -1;
               if(chkZ == -1)
               {
                 alert("Ungültige Postleitzahl!");
                 document.Formular.PLZ.focus();
                 return false;
                }
            if(document.Formular.PLZ.value.length != 5)
                {
               alert document.Formular.PLZ.value + " ist keine fünfstellige PLZ.")
               return false;
            }
            </script>
            </head>

            <body><form name="Formular" action="suche4.php" onSubmit="return chkFormular()" method="post">
                <select name="Vertriebsl">
                <option value="Vertriebsl">Alle</option>
                <option value="Bau- und Gartencenter">Bau- und Gartencenter</option>
                <option value="Direkt">Direkt</option>
                <option value="Sky">Sky</option>
                <option value="Plaza">Plaza</option>
                <option value="SEH">SEH</option>
                <option value="Wandmaker">Wandmaker</option>
              </select>
            PLZ: <input type="text" name="PLZ" value="" maxlength="5" size="5" /><br />
            <input type="submit" name="submit_button" value="Suchen" />
            </body>
            </html>

            1. <input type="submit" name="submit_button" value="Suchen" />

              <input type="submit" name="submit_button" value="Suchen" onClick="return chkFormular()"/>

              1. <input type="submit" name="submit_button" value="Suchen" />

                <input type="submit" name="submit_button" value="Suchen" onClick="return chkFormular()"/>

                funktioniert nicht

                1. <input type="submit" name="submit_button" value="Suchen" />

                  <input type="submit" name="submit_button" value="Suchen" onClick="return chkFormular()"/>
                  funktioniert nicht

                  <form ... onSubmit="return chkFormular()">

                  Grüße
                  Andreas

                2. Also noch mal ich! <g>

                  Du must im onSubmit="return chkFormular()" schreiben! Also nur das return vergessen

                  Noch mal der geamte Code:
                   <html><head><title>Test</title>
                   <script language="JavaScript">
                   function chkFormular() {
                   var chkZ = 1;
                      for(i=0;i<document.Formular.PLZ.value.length;++i)
                        if(document.Formular.PLZ.value.charAt(i) < "0"
                        || document.Formular.PLZ.value.charAt(i) > "9")
                          chkZ = -1;
                      if(chkZ == -1)
                      {
                        alert("Ungültige Postleitzahl!");
                        document.Formular.PLZ.focus();
                        return false;
                       }
                   if(document.Formular.PLZ.value.length != 5)
                       {
                      alert(document.Formular.PLZ.value + " ist keine fünfstellige PLZ.")
                      return false;
                   }
                  }
                   </script>
                   </head>

                  <body><form name="Formular" action="suche4.php" onsubmit="return chkFormular()" method="post">
                       <select name="Vertriebsl">
                       <option value="Vertriebsl">Alle</option>
                       <option value="Bau- und Gartencenter">Bau- und Gartencenter</option>
                       <option value="Direkt">Direkt</option>
                       <option value="Sky">Sky</option>
                       <option value="Plaza">Plaza</option>
                       <option value="SEH">SEH</option>
                       <option value="Wandmaker">Wandmaker</option>
                     </select>
                   PLZ: <input type="text" name="PLZ" value="" maxlength="5" size="5"><br>
                   <input type="submit" name="submit_button" value="Suchen">
                   </body>
                   </html>

                  P.S.: Syntaks fehler behoben! zu deinem Posting.

      2. Hi,

        Ich denke so müste es klappen habe es nicht ausprobiert

        if(document.Formular.PLZ.value.length > 4 && document.Formular.PLZ.value.length < 6 )
            {
           alert document.Formular.PLZ.value + " ist keine gültige PLZ.")
           return false;
         }

        Du fragst einfach die lenge des Eingabe Feldes ab.

        Ich hoffe ich könnte dir weiterhelfen

        Bis dann

        Boris

        1. if(document.Formular.PLZ.value.length > 4 && document.Formular.PLZ.value.length < 6 )

          if(document.Formular.PLZ.value.length != 5)
          ist ein wenig kürzer!

          1. if(document.Formular.PLZ.value.length != 5)
            ist ein wenig kürzer!

            Jup <g> Hätte man auch dran denken können !

            Boris

          2. Hi!

            if(document.Formular.PLZ.value.length != 5)
            ist ein wenig kürzer!

            Vielleicht noch ne Überprüfung ob es nur Zahlen sind:

            var chkZ = 1;
               for(i=0;i<document.Formular.PLZ.value.length;++i)
                 if(document.Formular.PLZ.value.charAt(i) < "0"
                 || document.Formular.PLZ.value.charAt(i) > "9")
                   chkZ = -1;
               if(chkZ == -1)
               {
                 alert("Ungültige Postleitzahl!");
                 document.Formular.PLZ.focus();
                 return false;
                }

            Vielleicht geht das ja auch einfacher?

            Grüße
            Andreas

          3. if(document.Formular.PLZ.value.length > 4 && document.Formular.PLZ.value.length < 6 )

            if(document.Formular.PLZ.value.length != 5)
            ist ein wenig kürzer!

            wieso geht das denn nicht, bin ich blind??
            <html><head><title>Test</title>
            <script language="javascrip">
            if(document.Formular.PLZ.value.length != 5)
                {
               alert document.Formular.PLZ.value + " ist keine fünfstellige PLZ.")
               return false;
             }
            </script>
            </head>

            <body><form name="Formular" action="suche4.php" method="post">
                <select name="Vertriebsl">
                <option value="Vertriebsl">Alle</option>
                <option value="Bau- und Gartencenter">Bau- und Gartencenter</option>
                <option value="Direkt">Direkt</option>
                <option value="Sky">Sky</option>
                <option value="Plaza">Plaza</option>
                <option value="SEH">SEH</option>
                <option value="Wandmaker">Wandmaker</option>
              </select>
            PLZ: <input type="text" name="PLZ" value="" maxlength="5" size="5" /><br />
            <input type="submit" name="submit_button" value="Suchen" />
            </body>
            </html>

            1. if(document.Formular.PLZ.value.length > 4 && document.Formular.PLZ.value.length < 6 )

              if(document.Formular.PLZ.value.length != 5)
              ist ein wenig kürzer!
              wieso geht das denn nicht, bin ich blind??
              <html><head><title>Test</title>
              <script language="javascrip">
              if(document.Formular.PLZ.value.length != 5)
                  {
                 alert document.Formular.PLZ.value + " ist keine fünfstellige PLZ.")
                 return false;
              }
              </script>
              </head>

              <body><form name="Formular" action="suche4.php" method="post">
                  <select name="Vertriebsl">
                  <option value="Vertriebsl">Alle</option>
                  <option value="Bau- und Gartencenter">Bau- und Gartencenter</option>
                  <option value="Direkt">Direkt</option>
                  <option value="Sky">Sky</option>
                  <option value="Plaza">Plaza</option>
                  <option value="SEH">SEH</option>
                  <option value="Wandmaker">Wandmaker</option>
                </select>
              PLZ: <input type="text" name="PLZ" value="" maxlength="5" size="5" /><br />
              <input type="submit" name="submit_button" value="Suchen" />
              </body>
              </html>

              Da fehlt irgendwo ein onSubmit - wo wird denn das sonst ausgeführt?
              Grüße
              Andreas

            2. Hi,

              So Funktioniert es!

              Wie Andreas schon sagte: hattest den den aufruf der funktion vergessen!

              Viel Spass

              Boris

              <html><head><title>Test</title>
               <script language="JavaScript">
               function CheckFormular() {
                  if(document.Formular.PLZ.value.length != 5)
                  {
                 alert(document.Formular.PLZ.value + " ist keine gültige PLZ.")
                 return false;
               }
               }
               </script>
               </head>

              <body><form name="Formular" action="suche4.php" method="post">
                   <select name="Vertriebsl">
                   <option value="Vertriebsl">Alle</option>
                   <option value="Bau- und Gartencenter">Bau- und Gartencenter</option>
                   <option value="Direkt">Direkt</option>
                   <option value="Sky">Sky</option>
                   <option value="Plaza">Plaza</option>
                   <option value="SEH">SEH</option>
                   <option value="Wandmaker">Wandmaker</option>
               </select>
               PLZ: <input type="text" name="PLZ" value="" maxlength="5" size="5"><br>
              <INPUT type="submit" value="senden" onClick="return CheckFormular();">
              </form>
              </body>
               </html>

              1. Hi,

                So Funktioniert es!

                Wie Andreas schon sagte: hattest den den aufruf der funktion vergessen!

                Viel Spass

                Boris

                <html><head><title>Test</title>
                <script language="JavaScript">
                function CheckFormular() {
                    if(document.Formular.PLZ.value.length != 5)
                    {
                   alert(document.Formular.PLZ.value + " ist keine gültige PLZ.")
                   return false;
                }
                }
                </script>
                </head>

                <body><form name="Formular" action="suche4.php" method="post">
                     <select name="Vertriebsl">
                     <option value="Vertriebsl">Alle</option>
                     <option value="Bau- und Gartencenter">Bau- und Gartencenter</option>
                     <option value="Direkt">Direkt</option>
                     <option value="Sky">Sky</option>
                     <option value="Plaza">Plaza</option>
                     <option value="SEH">SEH</option>
                     <option value="Wandmaker">Wandmaker</option>
                </select>
                PLZ: <input type="text" name="PLZ" value="" maxlength="5" size="5"><br>
                <INPUT type="submit" value="senden" onClick="return CheckFormular();">
                </form>
                </body>
                </html>

                ich danke diesem forum

              2. sehr schön,
                vielen dank

                Hi,

                So Funktioniert es!

                Wie Andreas schon sagte: hattest den den aufruf der funktion vergessen!

                Viel Spass

                Boris

                <html><head><title>Test</title>
                <script language="JavaScript">
                function CheckFormular() {
                    if(document.Formular.PLZ.value.length != 5)
                    {
                   alert(document.Formular.PLZ.value + " ist keine gültige PLZ.")
                   return false;
                }
                }
                </script>
                </head>

                <body><form name="Formular" action="suche4.php" method="post">
                     <select name="Vertriebsl">
                     <option value="Vertriebsl">Alle</option>
                     <option value="Bau- und Gartencenter">Bau- und Gartencenter</option>
                     <option value="Direkt">Direkt</option>
                     <option value="Sky">Sky</option>
                     <option value="Plaza">Plaza</option>
                     <option value="SEH">SEH</option>
                     <option value="Wandmaker">Wandmaker</option>
                </select>
                PLZ: <input type="text" name="PLZ" value="" maxlength="5" size="5"><br>
                <INPUT type="submit" value="senden" onClick="return CheckFormular();">
                </form>
                </body>
                </html>

          4. So, mein Vorschlag:

            <script type="text/javascript">
            <!--
             function isPLZ(rs)
              {
               if(isNaN(rs) == true || rs.length != 5)
                {
                 window,alert(rs + " ist keine gültige Postleitzahl.");
                }
              }
             isPLZ("123");
             isPLZ("01440");
            //-->
            </script>

            Der übergebebe Parameter sollte eine Zeichenkette sein.

            Gruß
            Norbert

        2. <lol> Habe mich mit den Kleiner Größer Zeichen vertahn. <g>
          Also genau anderesherum abfragen

          Hi,

          Ich denke so müste es klappen habe es nicht ausprobiert

          if(document.Formular.PLZ.value.length > 4 && document.Formular.PLZ.value.length < 6 )
              {
             alert document.Formular.PLZ.value + " ist keine gültige PLZ.")
             return false;
          }

          Du fragst einfach die lenge des Eingabe Feldes ab.

          Ich hoffe ich könnte dir weiterhelfen

          Bis dann

          Boris