hi,
Just a improvement i suggest as this command works in netscape as well as
in IE.
if
(document.form.select_fld_name[document.form.select_fld_name.options.selectedIndex].value

== "0")

The mentioned one
if (document.form.fieldname[selectedIndex].value == ""){
may not work in netscape.

thanks
regards
Sanjeevi


---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material.  Any review, retransmission,  dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited.   If you received
this in error,  please contact the sender and delete the material from any
computer.
-- Phoenix Global Solutions (India) Pvt Ltd., www.pgsolutions.com
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


                                                                                       
                              
                    "Steve Reich"                                                      
                              
                    <sr_lists@pagec        To:     CF-Talk <[EMAIL PROTECTED]> 
                              
                    oders.com>             cc:                                         
                              
                                           Subject:     Re: Javascript Validation & 
Coldfusion ?                     
                    08/16/01 05:52                                                     
                              
                    PM                                                                 
                              
                    Please respond                                                     
                              
                    to cf-talk                                                         
                              
                                                                                       
                              
                                                                                       
                              



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/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to