PLZ überprüfen
Klobidop
- javascript
0 Ole0 Andreas0 ole0 Klobidop0 Klobidop0 Markus Möller0 Klobidop0 Andreas0 Boris Christ
0 Boris Chris
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.
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-)>
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
hi Andreas
punkt für dich :)
bin einfach überarbeitet und betriebsblind...
so long
ole
(8-)>
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>
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>
<input type="submit" name="submit_button" value="Suchen" />
<input type="submit" name="submit_button" value="Suchen" onClick="return chkFormular()"/>
<input type="submit" name="submit_button" value="Suchen" />
<input type="submit" name="submit_button" value="Suchen" onClick="return chkFormular()"/>
funktioniert nicht
<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
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.
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
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!
if(document.Formular.PLZ.value.length != 5)
ist ein wenig kürzer!
Jup <g> Hätte man auch dran denken können !
Boris
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
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>
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
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>
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
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>
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
<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