How do I [correctly] set up my registration form to ’remember’ the option in a select box if the user registration page is reloaded - i.e. something didn’t validate and the user is returned to the register page.
Currently I’ using:
<label>Salutation:<span class="form-required">*</span></label>
<select name="salutation:required" class="form-select" id="salutation" >
<option selected="selected"> </option>
<option value="Dr." [[!If? &subject=`[[+salutation]]` &operator=`EQ` &operand=`Dr,.` &then=`selected="selected"` ]]>Dr.</option>
<option value="Mr." [[!If? &subject=`[[+salutation]]` &operator=`EQ` &operand=`Mr.` &then=`selected="selected"` ]] >Mr.</option>
<option value="Mrs." [[!If? &subject=`[[+salutation]]` &operator=`EQ` &operand=`Mrs.` &then=`selected="selected"` ]]>Mrs.</option>
<option value="Ms." [[!If? &subject=`[[+salutation]]` &operator=`EQ` &operand=`Ms.` &then=`selected="selected"` ]]>Ms.</option>
</select>
<span class="error">[[+error.salutation]]</span>
And that works, but it seems kinda messy - is there a better/more correct way to do this properly?
Also - how do I validate check boxes/radio buttons... I have a set of radio buttons, a selection is required, but
<p>Agreement: I have read and I agree to the <a href="[[~217]]" target="_blank">conditions and terms of use</a>.</p>
<ul>
<li>
<label>No, I do not agree to the terms and conditions</label>
<input type="radio" id="eula-agreement-disagree" name="eula-agreement" value="No, I do not agree to the terms and conditions" class="form-radio" />
</li>
<li>
<label>Yes, I agree to the terms and conditions</label>
<input type="radio" id="eula-agreement-agree" name="eula-agreement:required" value="Yes, I agree to the terms and conditions" class="form-radio" />
</li>
</ul>
<span class="error">[[+error.eula-agreement]]</span>
Does not work... I also have another radio set of 5 options, one has to be selected but not one in particular, just so long as one is.
-thanks
-sean