PDA

View Full Version : I need some help with validation


Marc
03-04-2009, 07:10 AM
hi,
i made a form but on the very beginnig i have a list/menu with 2 entries. the validation works fine for all other fields, exept for the list/menu.
here is the script, i hope anybody can help me with this

thank you

<label for="Anrede" >
Anrede: <br />
<select name="Anrede" id="Anrede">
<option selected="selected">Bitte Ausw&auml;hlen</option>
<option value="Herr" <?php if (!(strcmp("Herr", (ValidatedField("contact","Anrede"))))) {echo "selected=\"selected\"";} ?>>Herr</option>
<option value="Frau" <?php if (!(strcmp("Frau", (ValidatedField("contact","Anrede"))))) {echo "selected=\"selected\"";} ?>>Frau</option>
</select>
<input name="addblock" type="text" id="addblock" style="display:none" value="" />
<br />
<?php
if (ValidatedField("contact","contact")) {
if ((strpos((",".ValidatedField("contact","contact").","), "," . "1" . ",") !== false || "1" == "")) {
if (!(false)) {
?>
<p class="promo">* Bitte geben Sie ihre Anrede ein</p>
<?php //WAFV_Conditional contact.php contact(1:)
}
}
}?>

Ray Borduin
03-04-2009, 09:11 AM
add : value="" to your top option.

Marc
03-04-2009, 10:37 AM
hi ray,
i did this before but it won't work

Ray Borduin
03-04-2009, 10:38 AM
It should... what is your validation code on top of the page?

Marc
03-04-2009, 10:46 AM
ray, i did it again now with the value. but the selected value "Auswahl" means only "select" (in the code below it is in german). so if i don't touch the list/menu the validation don't tell me that i should choose between "Herr" or "Frau".

the validation code on top = $WAFV_Errors .= WAValidateRQ(((isset($_POST["Anrede"]))?$_POST["Anrede"]:"") . "",true,1);


<select name="Anrede" id="Anrede">
<option value selected="selected">Auswahl</option>
<option value="Herr" <?php if (!(strcmp("Herr", (ValidatedField("contact","Anrede"))))) {echo "selected=\"selected\"";} ?>>Herr</option>
<option value="Frau" <?php if (!(strcmp("Frau", (ValidatedField("contact","Anrede"))))) {echo "selected=\"selected\"";} ?>>Frau</option>
</select>
<input name="addblock" type="text" id="addblock" style="display:none" value="" />
<br />
<?php
if (ValidatedField("contact","contact")) {
if ((strpos((",".ValidatedField("contact","contact").","), "," . "1" . ",") !== false || "1" == "")) {
if (!(false)) {
?>
<p class="promo">* Bitte geben Sie ihre Anrede ein</p>
<?php //WAFV_Conditional contact.php contact(1:)
}
}
}?>

Ray Borduin
03-04-2009, 11:08 AM
make sure it has:

<option value="" selected="selected">Auswahl</option>

other than that it should work.

Marc
03-04-2009, 11:15 AM
ray

this solved my problem ;)

thank you very much