First I recommend you send a blank email to
[EMAIL PROTECTED] and join JS-Jive, the javascript list.
You'll get lots of help with Javascript.
But to answer your question, you need to access the selectedIndex property
of a select box to validate it....
<script>
function validateSelect(){
if (document.form.fieldname[selectedIndex].value == ""){
alert("Please select an option in the select box.");
return false;
}
}
</script>
onsubmit="return validateSelect()"
This assumes that you have an option in the select box with an empty
value...
<option value="">(select option)
HTH,
Steve
<[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi
>
> How do you add validation to drop down form select boxes using Javascript.
I have added validation (shown below in the js) for the two text input
fields but need to build in validation for the two select boxes and also a
CFFile field as these are required fields in the form, any ideas on how to
integrate this into what I have below?
>
> <SCRIPT LANGUAGE="JavaScript">
>
> <!-- Begin
> function checkFields() {
> missinginfo = "";
> if (document.form.filename.value == "") {
> missinginfo += "\n - Title of the File Uploaded";
> }
> if (document.form.filesummary.value == "") {
> missinginfo += "\n - Descriptive Summary of Uploaded File";
> }
>
> if (missinginfo != "") {
> missinginfo ="
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists