I would recommend you to take a look at qform API.


http://www.pengoworks.com/qforms/docs/


Qasim

-----Original Message-----
From: Austin Govella [mailto:[EMAIL PROTECTED]
Sent: Wednesday, February 11, 2004 9:06 PM
To: CF-Talk
Subject: Custom tag for data validation - tell me if I'm crazy

I'm working on a modular way to validate form data and
display error messages across all of my applications.

Once a form is submitted, I want to:

1. Make sure the form data meets certain requirements
(required, alphanumeric, whatever...).

2. If there's an error, redisplay the form with the original
responses filled in.

3. Highlight the field that had the errors.

4. Display the error messages *near* the field that had the
error.

So, my proposed solution uses a custom tag, cf_validate,
that requires two attributes, the variable and the variable
name. A number of optional attributes indicate how the
variable needs to be tested. For example, to validate the
form data for form.foobar:

<cf_validate
VariableName = "foobar"
VariableValue = "#foobar#"
Required = "yes"
StringType = "alphanumeric">

If there's an error we set three variables:

1. caller.form_type = "error"
2. caller.foobar_class = "error"
3. caller.foobar_message[] = "error message"

Form_type is a flag that tells us to redisplay the form
(instead of inserting/updating the record).

My form elements are set as list items, so Foobar_class sets
the class to <li class="error"> (so I can visually note the
error).

And the array, foobar_message[], displays any existing error
messages. I'm planning on looping through the array and
displaying them in a numbered list so the user knows exactly
how many ways they suck.

So, on my whiteboard, it looks like it works, but that's a
lot of code and debugging to go through for it to end up not
being possible. Am I missing any big obstacles? Is it
categorically impossible?

Many thanks for the guidance,
--
Austin
  _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to