Thanks so much for your help Kola and Nathan! :-)


-----Original Message-----
From: Kola Oyedeji [mailto:[EMAIL PROTECTED]
Sent: 10 March 2004 16:46
To: CF-Talk
Subject: RE: cfqueryparam, cfcatch 'n cftry


Stuart

Hi, a couple of things. First of all if you are checking if  form fields
have a value - either trim all your form fields before your validation
or trim then when testing e.g.

<cfif trim(form.PropertyDataVillageTown) is "">

or even <cfif len(trim(form.PropertyDataVillageTown)) eq 0 >

Second thing is as in essence you're building up a list so you could do
this for each validation clause to make your code a bit more readable

<cfif trim(form.PropertyDataVillageTown) is "">
  <cfset   MessageAlert = listAppend(MessageAlert,  "<font
color='b23f3f'><b>Village/Town</b></font> must have a value." ,  "<br")
>
</cfif>

Using "<br>" as the delimiter .

Also you may want to wrap the field names in a style sheet class
<span class='fieldHighlight''> Village/Town</span> which would mean you
wont have to change your code (only your stylesheet) when the designer
decides to use #b23f3f as the background colour ;-)

Then you need only check the length of the list once at the end to see
if an error occurred

<cfif listLen(MessageAlert) >
            <cfset ErrorFound = "yes" >
</cfif>

Finally you would have to add additional validation before reaching the
SQL statement if you want to ensure a field has a minimum length, this
can be done on the database but I wouldn't do it that way!

Hope that helps

Kola

-----Original Message-----
From: Stuart Kidd [mailto:[EMAIL PROTECTED]
Sent: 10 March 2004 15:54
To: CF-Talk
Subject: cfqueryparam, cfcatch 'n cftry

Hi guys,

In my cfcatch i've got a bunch of <cfif>'s checking to make sure all
parts of my form were correct.

e.g.:

<cfif form.PropertyDataVillageTown is ""><cfset MessageAlert =
MessageAlert & "<font color='b23f3f'><b>Village/Town</b></font> must
have a value.<br>"><cfset ErrorFound = "yes"></cfif>
<cfif form.PropertyDataCountyState is ""><cfset MessageAlert =
MessageAlert & "<font color='b23f3f'><b>County/State</b></font> must
have a value.<br>"><cfset ErrorFound = "yes"></cfif>
<cfif form.PropertyDataPostcodeZip is ""><cfset MessageAlert =
MessageAlert & "<font color='b23f3f'><b>Postcode/Zip</b></font> must
have a value.<br>"><cfset ErrorFound = "yes"></cfif>

However, all these actions will only take place if there is an error
triggered.

I have one field which is a description and i'd like to trigger an error
if it is less than 10 characters in length and more than 120.  When i am
using cfqueryparam in my SQL i noticed i can have such a line:

<cfqueryparam cfsqltype="cf_sql_longvarchar" maxlength="120">

Will this the right thing to trigger an error in case it's more than 120
characters??  How about if i want to trigger the error if it's less than
10 characters too, can that not be done.

BTW: i just chucked in that cf_sql_longvarchar because i didn't know
what to use.

Thanks,

Stu
  _____
  _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to