I think it's probably a matter of preference, but if you're already versed in the DOM, IMHO ... it's better to roll your own validation. I know of a few folks that have used the js that cf uses to validate, but the majority generally write their own. Personnaly I think the js cf writes is ugly ;). It gives you the opportunity to write scripts that are, shall we say ... more elegant ;).
Bob > -----Original Message----- > From: Brian Petti [mailto:[EMAIL PROTECTED] > Sent: Thursday, June 07, 2007 4:25 PM > To: CF-Newbie > Subject: Re: javascript message not working > > Okay thank you Bob. So basically you recommend that I should not even > use the built in validation? I've been designing and programming for > about 8 years, but I recently just started learning ColdFusion. I've > done other projects in ColdFusion MX on different servers using the > same type of coding as below, and didn't have any problems. I'm > guessing that it's my host's problem. I guess I get what I pay for at > HostDepartment. > > > On Jun 7, 2007, at 4:17 PM, Bob Imperial wrote: > > > Try using this script if you like and be sure to give your form a > > name and > > use it in place of "formname" in the if statements, this should > > work for you > > using a plain html form. > > > > <script type=text/javascript> > > function validateForm() { > > var allOk = true; > > var errorString = "The following are required fields:\n"; > > > > > > // validate their email > > var validEmail = > > /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; > > if (!validEmail.test(document.formname.email_address.value)) > > { > > allOk = false; > > errorString += "\n- Email Address"; > > } > > // require first name > > if (!document.formname.password.value) { > > allOk = false; > > errorString += "\n- Password"; > > } > > > > if (!allOk) > > { > > alert(errorString); > > return false; > > } > > > > return allOk; > > } > > </script> > > > >> -----Original Message----- > >> From: Brian Petti [mailto:[EMAIL PROTECTED] > >> Sent: Thursday, June 07, 2007 3:29 PM > >> To: CF-Newbie > >> Subject: Re: javascript message not working > >> > >> Thank you for responding. I do use CFForm tags. Here a snippet of the > >> code I use: > >> > >> <cfform action="login.cfm" method="post"> > >> <table border="0" cellspacing="0" cellpadding="5"> > >> <tr> > >> <td valign="top" align="left" > >> colspan="2"><h2>Administrator Log > >> In:</h2></td> > >> </tr> > >> <cfif isdefined('URL.message')> > >> <cfif URL.message is 'invalid'> > >> <tr> > >> <td valign="top" align="left" colspan="2"><font > >> color="#990000" > >> size="1">The log in information you provided is incorrect. Please try > >> again.</font></td> > >> </tr> > >> </cfif> > >> <cfif URL.message is 'expired'> > >> <tr> > >> <td valign="top" align="left" colspan="2"><font > >> color="#990000" > >> size="1">Your session has timed out. Please log in again.</font></td> > >> </tr> > >> </cfif> > >> </cfif> > >> <tr> > >> <td valign="middle" align="left"><B>Email > >> Address</B></td> > >> <td valign="middle" align="left"><cfinput > > type="text" > >> name="email_address" size="15" maxlength="55" required="yes" > >> message="Please fill in both fields before submitting."></td> > >> </tr> > >> <tr> > >> <td valign="middle" > > align="left"><B>Password</B></td> > >> <td valign="middle" align="left"><cfinput > >> type="password" > >> name="password" size="15" maxlength="55" required="yes" > >> message="Please fill in both fields before submitting."></td> > >> </tr> > >> <tr> > >> <td valign="top" align="left"> </td> > >> <td valign="top" align="left"><input type="submit" > >> value=" Log in > >> "></td> > >> </tr> > >> </table> > >> </cfform> > >> > >> > >> > >> > >> On Jun 7, 2007, at 3:25 PM, Bob Imperial wrote: > >> > >>> Brian I believe you need to use cfform and cfinput to define your > >>> fields in > >>> order to use the built in validation in Coldfusion. I could be > >>> wrong as I > >>> don't use them. I don't think I've ever used the built in stuff, > >>> always roll > >>> my own, have more control over them that way. > >>> HTH > >>> > >>> Bob > >>> > >>>> -----Original Message----- > >>>> From: Brian Petti [mailto:[EMAIL PROTECTED] > >>>> Sent: Thursday, June 07, 2007 1:35 PM > >>>> To: CF-Newbie > >>>> Subject: javascript message not working > >>>> > >>>> Hi all, > >>>> I am having trouble making the required field message window pop > >>>> up. > >>>> I was hoping that someone could just view the source code and > >>>> see if > >>>> there is a problem with how I wrote it. > >>>> > >>>> Here is the test directory: http://65.19.182.10/admin/ > >>>> > >>>> Just click the submit button. It should throw the error, but > >>>> nothing > >>>> happens. > >>>> > >>>> HostDepartment.com did not even have a CFIDE directory, so I > >>>> uploaded > >>>> the "scripts" directory where the cfform.js file is located. I'm > >>>> not > >>>> sure if that is an issue or not. > >>>> > >>>> Any help is appreciated. > >>>> > >>>> Thank you! > >>>> Brian > >>>> > >>>> > >>>> > >>> > >>> > >> > >> > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Deploy Web Applications Quickly across the enterprise with ColdFusion MX7 & Flex 2 Free Trial http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJU Archive: http://www.houseoffusion.com/groups/CF-Newbie/message.cfm/messageid:2815 Subscription: http://www.houseoffusion.com/groups/CF-Newbie/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15
