I have made changes and the form validation works but not 100% yet, I have a CFFile field that will allow users to upload ".pdf",".jpg",".gif" files, and the validation that is included with the script does not seem to picking up the following...........
1.) That there is an incorrect file format trying to be uploaded, when only pdf, jpg and gif files should be allowe to be uploaded. 2.) The form can still be submitted when the CFFile field is blank, but it is required to have a value I have been trying since the previous posts, tweaking the code to try to come up with a solution but with no success so would value a second opinion from you very much <SCRIPT LANGUAGE="JavaScript"> <!-- Begin function checkFields() { foundExt = true; 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.selectedIndex == 0 || document.form.area.selectedIndex == 1) missinginfo += "\n - Please select File Category"; if (document.form.dlos.selectedIndex == 0 || document.form.dlos.selectedIndex == 1) missinginfo += "\n - Please select an operating system"; ///START UPLOAD CODE if (document.form.UploadFile.value != "") { lcVal = document.form.UploadFile.value.toLowerCase(); foundExt = false; ext = new Array(".pdf",".jpg",".gif"); for (i=0; i<ext.length; i++) { if (lcVal.indexOf(ext[i]) >= 0) { foundExt = true; } } if (!foundExt) { alert("Only upload files that end in " + (extArray.join(" ")) + ".\n\nPlease select a new " + "file to upload and try again."); } } ///END UPLOAD CODE if (missinginfo != "") { missinginfo ="_____________________________\n" + "You failed to correctly fill in your:\n" + missinginfo + "\n_____________________________" + "\nPlease re-enter the required details and submit again!"; alert(missinginfo); return false; } if (missinginfo == "" && foundExt) { submit_form('Form', 'content'); ///here 'tis return true; } else { return false; } } // End --> </script> In my body tag <body onLoad="setupMenu(document.Form)"; background="white" topmargin=4 bgcolor=#FFFFFF text=#000000 link=#000099 vlink=#000099 alink=#FF0000 onSubmit="return checkFields()"> In the form tag <form action="dltestaction.cfm" ENCTYPE="multipart/form-data" method="post" name="form" id="Form" onSubmit="return checkFields();"> Ian ----- Original Message ----- From: "Tim Painter" <[EMAIL PROTECTED]> To: "CF-Talk" <[EMAIL PROTECTED]> Sent: Wednesday, September 25, 2002 2:34 PM Subject: Re: Javascript Validation for Form Selects in CF ? > Ian, > You have a couple of extra left curly braces after the check on dlos and > area -- > > missinginfo += "\n - Please select an operating system"; > } <--- Remove this > > > missinginfo += "\n - Please select the required area"; > } <--- and this one too. > > Tim P. > > ----- Original Message ----- > From: "Ian Vaughan" <[EMAIL PROTECTED]> > To: "CF-Talk" <[EMAIL PROTECTED]> > Sent: Wednesday, September 25, 2002 9:06 AM > Subject: Re: Javascript Validation for Form Selects in CF ? > > > > 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">  <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>  <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 ---></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/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists