In a form, there are radio buttons for the user to select:
<li>
<label for="full professor"><span class="required">&##8727;</span>Is the candidate a full professor?</label>
<input type="radio" name="fullProfessor" value="yes" tabindex="4" />Yes<input type="radio" name="fullProfessor" value="no" tabindex="5" checked/>No </li>
<li>
<label for="more than ten"><span class="required">&##8727;</span>Has the candidate been here for more than 10 years?</label>
<input type="radio" name="moreThanTen" value="yes" tabindex="6" />Yes<input type="radio" name="moreThanTen" value="no" tabindex="7" checked/>No </li>
<li>
<label for="past nominee"><span class="required">&##8727;</span>Has the candidate been nominated for this award in the last 3 years?</label>
<input type="radio" name="pastNominee" value="yes" tabindex="8" />Yes<input type="radio" name="pastNominee" value="no" tabindex="9" checked/>No </li>
I’m not certain how to param them. The typical code I use is:
<cfparam
name="FORM.fullProfessor"
type="string"
default=""
/>
Is the type string even though it doesn’t accept a string like a textfield would?
To validate the radio button, is using:
<!--- Validate campus address. --->
<cfif NOT Len( FORM.fullProfessor)>
<cfset ArrayAppend(
arrErrors,
"Error message here."
) />
</cfif>
Lastly, maintaining the users’ selection after validating the page, how may I ensure this?
<cfif isDefined(form.fullProfessor) selected="yes">?
Thanks.
If you are using Yes and No you can treat them like booleans.
and
and
You could also use a framework for validating your forms, I’d highly recommend validate this: http://www.validatethis.org/