Changed the code to and added a name one of the form fields but a javascript
syntx error is occuring? what could cause this in the code below??

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
function checkFields() {
missinginfo = "";
if (document.form.dltitle.value == "") {
missinginfo += "\n     -  Title of the File Uploaded";
}
if (document.form.dlsummary.value == "") {
missinginfo += "\n     -  Descriptive Summary of Uploaded File";
}

if (document.form.dlos.selectedIndex == 0 ||
document.form.dlos.selectedIndex == 1)
    missinginfo += "\n - Please select an operating system";
    }

if (document.form.area.selectedIndex == 0 ||
document.form.area.selectedIndex == 1)
    missinginfo += "\n - Please select the required area";
    }

if (missinginfo != "") {
missinginfo ="_____________________________\n" +
"You failed to correctly fill in the:\n" +
missinginfo + "\n_____________________________" +
"\nPlease re-enter the required details and submit again!";
alert(missinginfo);
return false;
}
else return true;
}
//  End -->
----- Original Message -----
From: "Tim Painter" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Wednesday, September 25, 2002 11:53 AM
Subject: Re: Javascript Validation for Form Selects in CF ?


> To check the selected value of a select, use
>
> if (document.form.dlos[document.form.dlos.selectedIndex].value == '')
etc.
>
> also, your file description select doesn't have a name.
>
> HTH,
> Tim P.
> ----- Original Message -----
> From: "Ian Vaughan" <[EMAIL PROTECTED]>
> To: "CF-Talk" <[EMAIL PROTECTED]>
> Sent: Wednesday, September 25, 2002 6:14 AM
> Subject: Javascript Validation for Form Selects in CF ?
>
>
> > Hi
> >
> > I am trying to add javascipt validation to my form fields before the
data
> is
> > submitted to the database via coldfusion, however it is not working
> > correctly and would appreciate any help anybody on the list can give.
> >
> > I am not getting any javascript error messages it is just ignoring the
> > fields that are left blank when they are required to have a value.  In
the
> > example below the first two fields
> >
> > form.dltitle is a text input field and form.dlsummary is a text area
field
> >
> > The form.area and form.dlos are select boxes, and these are the major
> > problem how can these be validated so that the user must select an
option
> > from the list ??
> >
> > This is the javascript
> >
> > <SCRIPT LANGUAGE="JavaScript">
> >
> > <!-- Begin
> > function checkFields() {
> > missinginfo = "";
> > if (document.form.dltitle.value == "") {
> > missinginfo += "\n     -  Title of the File Uploaded";
> > }
> > if (document.form.dlsummary.value == "") {
> > missinginfo += "\n     -  Descriptive Summary of Uploaded File";
> > }
> > if(document.form.area.value == 1){
> >     missinginfo += "\n - Please select option for Sel1";
> >     }
> >
> > if(document.form.dlos.value == 1){
> >     missinginfo += "\n - Please select option for Sel2";
> >     }
> >
> > if (missinginfo != "") {
> > missinginfo ="_____________________________\n" +
> > "You failed to correctly fill in the:\n" +
> > missinginfo + "\n_____________________________" +
> > "\nPlease re-enter the required details and submit again!";
> > alert(missinginfo);
> > return false;
> > }
> > else return true;
> > }
> > //  End -->
> > </script>
> >
> >
> > <form action="dltestaction.cfm" ENCTYPE="multipart/form-data"
> method="post"
> > name="form" id="Form" onSubmit="return checkFields();">
> >
> >
> > <input name="dltitle" class=mini size="40"
> >
onkeydown=onKeyDown="textCounter(this.form.dltitle,this.form.remLen,35);"
> > onKeyUp="textCounter(this.form.dltitle,this.form.remLen,35);"
MESSAGE="You
> > must enter a shortened headline for this story to be displayed on the
> > homepage" REQUIRED="YES">&nbsp <input readonly type="text" name="remLen"
> > size="3" class=mini maxlength=3 value="35"> <font class=modtxt><span
> > id="prev_texto_2">characters left</span>
> >
> >
> > <textarea name="dlsummary" class=mini wrap="PHYSICAL" rows="4" cols="50"
> >
>
onkeydown=onKeyDown="textCounter(this.form.dlsummary,this.form.remLen1,200);
> > " onKeyUp="textCounter(this.form.dlsummary,this.form.remLen1,200);"
> > required="YES" message="You need to fill in the Comments
> > field"></textarea>&nbsp <input readonly class=mini type="text"
> > name="remLen1" size="3" maxlength=3 value="200"> <font
class=modtxt><span
> > id="prev_texto_2">characters left</span>
> > </font>
> >
> > <select size="1" style="font-size: 7.0pt; width: 183px; height: 20px;">
> >     <option selected>Select File Description ---&gt;</option>
> >     <option>Printer Drivers</option>
> >     <option>Software Drivers / Patches</option>
> >     <option>Internet Utilities / Tools</option>
> >  <option>Software</option>
> >  <option>Document Viewers</option>
> >     <option>Config Viewers</option>
> >   </select>
> >
> > <select size="1" name="dlos" style="font-size: 7.0pt; width: 183px;
> height:
> > 20px;">
> >     <option selected>What Operating System -></option>
> >     <option>Windows 95</option>
> >  <option>Windows 98+</option>
> >     <option>Windows NT</option>
> >     <option>Windows 2000</option>
> >     <option>Unix</option>
> >  <option>Linux</option>
> >  <option>Not Applicable</option>
> >   </select>
> >
> > <input type=submit name="submit" value="Submit Form!">
> > </form>
> >
> >
> 
______________________________________________________________________
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
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

Reply via email to