Forum OpenACS Q&A: ad_form: validating one form value against another

Using ad_form is it possible to validate one form value based on the value of another element?

Right now I need this to validate the traditional Password, and Password Again for fields to make sure both are the same. But I have in other places needed to reference the value of one element to compare it to another.

Posted by Don Baccus on
Sure, in the explicit validate block. All variables in the form are available at that point. The variable you give as the reference variable only serves to tell ad_form where to put the error message if the check isn't passed, it plays no role at all in the actual checking.

So in your example you'd probably do something like

-validate {
  { password_again
     { [string equal $password $password_again] }
     "learn to type, Dave!"