Forums

Validate-selection not working

shd 16 Sep, 2009
Hi,

Maybe I'm doing something wrong it was working in joomla 1.013x but not in Joomla 1.5x.
The other validations are working normal (so far), but the selected (select one) is not working.

The code of the selection:
<select name="achter" id="achter">
					<option value="achter" selected="selected">Selecteer aantal</option>
					<option <?php if($_POST['achter'] == '1') echo 'selected'; ?> value="1">1
					<option <?php if($_POST['achter'] == '2') echo 'selected'; ?> value="2">2
					<option <?php if($_POST['achter'] == '4') echo 'selected'; ?> value="4">4
					<option <?php if($_POST['achter'] == 'fullcolor') echo 'selected'; ?> value="fullcolor">Full color
					
					</select>



The whole code of the form:
<script language="javascript" type="text/javascript">



<!-- Begin

var dayName = new Array ("zondag", "maandag", "dinsdag", "woensdag", "donderdag", "vrijdag", "zaterdag")
var months=new Array(13);
months[1]="januari";
months[2]="februari";
months[3]="maart";
months[4]="april";
months[5]="mei";
months[6]="juni";
months[7]="juli";
months[8]="augustus";
months[9]="september";
months[10]="oktober";
months[11]="november";
months[12]="december";

var now=new Date
var time=new Date();
var lmonth=months[time.getMonth() + 1];
var date=time.getDate();
var year=time.getYear();
if (year < 2000)    
year = year + 1900; 

document.write("<center>" +""); 
document.write(dayName[now.getDay()] + " ")
document.write(date + " ");
document.write(lmonth + " " + year + "</center>");
// End -->
</script>
</center>
<div id="titel">
  <h1>Offerte aanvraag</h1>
</div>
<div class="container_chrono">
              <div class="box_chrono_groep">    
                <div class="beginnaast_chrono"><label>Aanhef</label>
                  
                  
                  <div class="box_chrono">
                    <select name="aanhef" id="aanhef">
					<option <?php if($_POST['aanhef'] == 'heer') echo 'selected'; ?> value="heer">heer
					<option <?php if($_POST['aanhef'] == 'mevrouw') echo 'selected'; ?> value="mevrouw">mevrouw
					</select>
                  </div>
          </div>
              </div>
				<div class="box_chrono_groep">
				  <div class="naast_chrono"> 
				    <label>Voorletter(s)*</label>
				    
				    <div class="box_chrono">
				      <input name="voorletters" type="text" id="voorletters" value="<?php echo $_POST['voorletters']; ?>" size="10" maxlength="50" />
				    </div>
                  </div>
			  </div>
				<div class="box_chrono_groep">
                <div class="beginnaast_chrono">
                  <label>Achternaam*</label>
                  
                  <div class="box_chrono">
                    <input name="achternaam" type="text" id="achternaam" value="<?php echo $_POST['achternaam']; ?>" size="40" maxlength="50" />
                  </div>
                </div>
              </div>
              
              <div class="box_chrono_groep">
                <div class="beginnaast_chrono">
                  <label>Organisatie</label>
                  
                  <div class="box_chrono">
                    <input name="organisatie" type="text" id="organisatie" value="<?php echo $_POST['organisatie']; ?>" size="40" maxlength="50" />
                  </div>
                </div>
              </div>
              
              <div class="box_chrono_groep">
                <div class="beginnaast_chrono">
                  <label>Adres*</label>
                  
                  <div class="box_chrono">
                    <input name="adres" type="text" id="adres" value="<?php echo $_POST['adres']; ?>" size="40" maxlength="100" />
                  </div>
                </div>
              </div> 
              <div class="box_chrono_groep">
                <div class="beginnaast_chrono">
                  <label>Huisnummer*</label>
                  <div class="box_chrono">
                    <input name="huisnr" type="text" class="box_chrono" id="huisnr" value="<?php echo $_POST['huisnr']; ?>" size="5" maxlength="20" />
                  </div>
                </div>
              </div>
              <div class="box_chrono_groep">           
                <div class="beginnaast_chrono">
                  <label>Postcode*</label>
                  
                  <div class="box_chrono">
                    <input name="pccijfers" type="text" id="pccijfers" value="<?php echo $_POST['pccijfers']; ?>" size="4" maxlength="4" />
                    
                    <label></label>
                    
                    <input name="pcletters" type="text" id="pcletters" value="<?php echo $_POST['pcletters']; ?>" size="1" maxlength="2" />
                  </div> </div>
              </div>
			  
			  <div class="box_chrono_groep">
			    <div class="naast_chrono">
			      <label>Woonplaats*</label>
			      <div class="box_chrono">
			        <input name="woonplaats" type="text" id="woonplaats" value="<?php echo $_POST['woonplaats']; ?>" size="40" maxlength="70" />
		          </div>
		        </div>
		      </div>
			  <div class="box_chrono_groep">
                <div class="beginnaast_chrono">
                  <label>Telefoonnr.*</label>
                  <div class="box_chrono">
                    <input name="telnr" type="text" id="telnr" value="<?php echo $_POST['telnr']; ?>" size="14" maxlength="10" />
                    <span class="hint">Voorbeeld: 0572382323<br />
                  mobiel nummer is ook toegestaan</span>                </div>
                </div>
      </div>
			  
			    <div class="box_chrono_groep">
			      <div class="naast_chrono">
			        <label>Mobielnr. </label>
			        <div class="box_chrono">
			          <input name="mobiel" type="text" id="mobiel" value="<?php echo $_POST['mobiel']; ?>" size="14" maxlength="10" />
			          <span class="hint">Voorbeeld: 0612345678</span>                </div>
                  </div>
		      </div>
<div class="box_chrono_groep">
                <div class="beginnaast_chrono">
                  <label>E-mail adres*</label>
                  <div class="box_chrono">
                    <input name="emailone" type="text" id="email1" value="<?php echo $_POST['emailone']; ?>" size="40" maxlength="100">
                  </div>
                </div>
    </div>
              
			<div class="box_chrono_groep">
			      <div class="naast_chrono">
			        <label>Benodigd aantal kaarten*</label>
			        <div class="box_chrono">
			          <input name="aantal" type="text" id="aantal" value="<?php echo $_POST['aantal']; ?>" size="14" maxlength="10" />
                    </div>
                  </div>
    </div>
            
            
			    <div class="box_chrono_groep">    
                <div class="beginnaast_chrono">
                  <label>Aantal kleuren voor*</label>

                  <div class="box_chrono">
                    <select name="voor" id="voor">
					<option value="voor" selected="selected">Selecteer aantal</option>
					<option <?php if($_POST['voor'] == '1') echo 'selected'; ?> value="1">1
					<option <?php if($_POST['voor'] == '2') echo 'selected'; ?> value="2">2
					<option <?php if($_POST['voor'] == '4') echo 'selected'; ?> value="4">4
					<option <?php if($_POST['voor'] == 'fullcolor') echo 'selected'; ?> value="fullcolor">Full Color
					</select>
                  </div>
          </div>
          
          
          
              </div>  
			  
			  <div class="box_chrono_groep">    
                <div class="beginnaast_chrono">
                  <label>Aantal kleuren achter*</label>

                  <div class="box_chrono">
                    <select name="achter" id="achter">
					<option value="achter" selected="selected">Selecteer aantal</option>
					<option <?php if($_POST['achter'] == '1') echo 'selected'; ?> value="1">1
					<option <?php if($_POST['achter'] == '2') echo 'selected'; ?> value="2">2
					<option <?php if($_POST['achter'] == '4') echo 'selected'; ?> value="4">4
					<option <?php if($_POST['achter'] == 'fullcolor') echo 'selected'; ?> value="fullcolor">Full color
					
					</select>
                  </div>
          </div>
          
          
          
              </div>
              
              
              <div class="box_chrono_groep">    
                <div class="beginnaast_chrono">
                  <label>Voorzien van magneetstrip*</label>
                  
                  
                  <div class="box_chrono">
                    <select name="magneetstrip" id="magneetstrip">
					<option value="ja" selected="selected" <?php if($_POST['magneetstrip'] == 'ja') echo 'selected'; ?>value="ja">ja
					<option <?php if($_POST['magneetstrip'] == 'nee') echo 'selected'; ?> value="nee">nee
					</select>
                    
                   
                  </div>
          </div>
              </div>
             
             <div class="box_chrono_groep">    
                <div class="beginnaast_chrono">
                  <label>Voorzien van chip*</label>
                  
                  
                  <div class="box_chrono">
                    <select name="chip" id="chip">
					<option value="ja" selected="selected" <?php if($_POST['chip'] == 'ja') echo 'selected'; ?>value="ja">ja
					<option <?php if($_POST['chip'] == 'nee') echo 'selected'; ?> value="nee">nee
					</select>
                  </div>
          </div>
    </div> 
              
              
              <div class="box_chrono_groep">    
                <div class="beginnaast_chrono">
                  <label>Gewenste dikte*</label>
                  
                  
                  <div class="box_chrono">
                  
                   <select name="dikte" id="dikte">
					<option value="dikte" selected="selected">Selecteer dikte</option>
                    <option <?php if($_POST['dikte'] == '0.3 mm') echo 'selected'; ?> value="0.3 mm">0.3 mm
			        <option <?php if($_POST['dikte'] == '0.5 mm') echo 'selected'; ?> value="0.5 mm">0.5 mm
                    <option <?php if($_POST['dikte'] == '0.76 mm') echo 'selected'; ?> value="0.76 mm">0.76 mm
					</select>
                  </div>
          </div>
              </div>
            
            <div class="box_chrono_groep">    
                <div class="beginnaast_chrono">
                  <label>Dient de kaart middels thermoprint gepersonaliseerd te  worden?*</label>
                  
                  
                  <div class="box_chrono">
                    <select name="thermoprint" id="thermoprint">
					<option value="ja" selected="selected" <?php if($_POST['thermoprint'] == 'ja') echo 'selected'; ?>value="ja">ja
					<option <?php if($_POST['thermoprint'] == 'nee') echo 'selected'; ?> value="nee">nee
					</select>
                  </div>
          </div>
    </div>
              
              <div class="box_chrono_groep">    
                <div class="beginnaast_chrono">
                  <label>Dient de kaart ook door ons naar de eindgebruiker verzonden te worden?*</label>
                  
                  
                  <div class="box_chrono">
                    <select name="eindgebruiker" id="eindgebruiker">
					<option value="ja" selected="selected" <?php if($_POST['eindgebruiker'] == 'ja') echo 'selected'; ?>value="ja">ja
					<option <?php if($_POST['eindgebruiker'] == 'nee') echo 'selected'; ?> value="nee">nee
					</select>
                  </div>
          </div>
              </div>
              
              
              
              <div class="box_chrono_groep"> 
				     <div class="beginnaast_chrono">
				       <label >Wilt u a.u.b. hieronder kort de bedoelde toepassing omschrijven?</label>
				       
				       
				       <div class="box_chrono">
				         <textarea name="omschrijving" cols="45" rows="4" id="omschrijving"><?php echo $_POST['omschrijving']; ?></textarea>
		               </div>
			         </div>
    </div>
              
              
</div>
<div class="container_chrono">
			   <div class="box_chrono_groep">
                <div class="beginnaast_chrono">
                  
                  <label>
                  Vul hier de code (spam beveiliging)</label>    </div>
                  
                  <div id="antispam">{imageverification}          </div>
              </div>
              <div class="box_chrono_groep"> 
                <div class="beginnaast_chrono">
                  <label>E-mail adres ter controle*</label>
                  <div class="box_chrono">
                    <input name="emailtwo" type="text" id="email2" value="<?php echo $_POST['emailtwo']; ?>" size="40" maxlength="100">
                  </div>
                </div>
              </div>
              
              <div class="box_chrono_groep"> 
                <div class="beginnaast_chrono">
          
                  
                <input name="nieuwsbrief" type="checkbox" id="nieuwsbrief" value="ja"<?php echo (isset($_POST['nieuwsbrief']) && $_POST['nieuwsbrief']=='ja')? ' checked' : '';?>>Ik meld mij aan voor de nieuwsbrief.    
				 
			    </div>
	          </div>
              
              
              
              
              <div class="box_chrono_groep"> 
                <div class="beginnaast_chrono">
                  <input name="voorwaarden" type="checkbox" onClick="akkoord(this)" value="ja">

				  Ik ga akkoord met de <a title="voorwaarden Bestcards" onclick="window.open(this.href,'targetWindow','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,');return false;" href="http://www.bestcards.nl/informatie/algemene-voorwaarden.html" target="_blank"  >voorwaarden</a>.
                                
                  <br />
				  * verplichte velden </div>
	          </div>
              <div class="box_chrono_groep"> 
                <div class="beginnaast_chrono">
                  <input name="verzenden" type="Submit" disabled id="verzenden" value="Verzenden">
                  
				  <input name="annuleren" type="reset" onclick="MM_goToURL('parent','http://www.saunasalland.nl/index.php?option=com_content&task=view&id=75&Itemid=163');return document.MM_returnValue" value="Annuleren" />
                  <script type="text/javascript">
window.document.forms.ChronoContact_res.voorwaarden.checked=false;</script>
                </div>
              </div>
        </div>
  <div id="spacer"></div>   </div>
              
    <div id="date">value="<?php echo date("d-m-Y, H:i:s") ?>" </div>

 
     



Greetzz and tnx,
Stephanie
GreyHead 16 Sep, 2009
Hi Stephanie,

One of those options will always be selected. So the validation will always be passed and tt's working OK.

If you want to validate that a selection has been made then the first, default option needs to have value='' (and not include selected='selected').

Bob
shd 16 Sep, 2009
Tnx for the quick reply.

You are meaning:
<select name="voor" id="voor">
					<option value="voor" >Selecteer aantal</option>
					<option <?php if($_POST['voor'] == '1') echo 'selected'; ?> value="1">1
					<option <?php if($_POST['voor'] == '2') echo 'selected'; ?> value="2">2
					<option <?php if($_POST['voor'] == '4') echo 'selected'; ?> value="4">4
					<option <?php if($_POST['voor'] == 'fullcolor') echo 'selected'; ?> value="fullcolor">Full Color
					</select>


This is also not working.

Stephanie
GreyHead 16 Sep, 2009
Hi Stephanie,

No value='' not value='voor' Having a value is the same as being selected as far as the validation is concerned.
<option value="" >Selecteer aantal</option>

Bob
shd 16 Sep, 2009
Hi Bob,

It is working! :mrgreen:

Thanks again for your quick help and response.

regards,
Stephanie
This topic is locked and no more replies can be posted.