Here's a method I use that utilizes a procedure to validate:
In your form processing page code:
} -validate {
{value {[valid_value err $value]} $err }
}
"err" is a var parameter that is set by procedure validate_value. On error you set it with the appropriate error message.
And the procedure looks something like:
ad_proc -public valid_value {
err
value
} {
Validates value.
@return 1 if valid, $err == "". 0 if invalid, $err == descriptive string.
@param err name of var parameter, in caller's scope, that receives error description.
@param value the value to be validated.
} {
upvar 1 $err lerr
if {[string length $value] < 3} {
set lerr "\"value\" must be a string containing three or more characters"
return 0
}
set lerr ""
return 1
}
This might seem like overkill for this simple example, but more complex checks and/or recovery can be performed in a more complex situation.
/R