> I want to force the user to select a country code when submitting a form.
>
> The select box looks like:
>
> <cfselect name="countrycode" required="Yes" size="5" message="Please
> select a country code.">
> <option value="" <CFIF get04.CountryCode IS ''>selected</cfif>>Please
> select</option>
> <option value="AU" <CFIF get04.CountryCode IS 'AU'>selected</cfif>
> >Australia</option>
>
> etc.
>
> I do not want them to be able to select the "value=""" option.
>
> How to do this?
Unless you simply omit the empty, descriptive option, you'll have to
use JavaScript - something like this:
<script>
function checkCountryCode() {
if (document.forms[0].countrycode.selectedIndex == 0) {
window.alert('Please select a country code.');
return false;
}
}
</script>
<form ... onsubmit="return checkCountryCode();">
...
</form>
Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
http://training.figleaf.com/
Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
GSA Schedule, and provides the highest caliber vendor-authorized
instruction at our training centers, online, or onsite
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:339610
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm