On Wed, Jun 5, 2013 at 6:02 PM, Daniel Crisan <crisandan...@gmail.com> wrote:
> Hello,
>
> I have a form with 2 inputs (textboxes, checkboxes, doesn't matter) and I
> need to add a validator for another field only if one of the inputs is equal
> to some value.
>
> Is this possible?

Sure, by using a general form validator.  Have a look at the following snippet:

signup = form.Form(
    form.Textbox('username'),
    form.Password('password'),
    form.Password('password_again'),
    validators = [form.Validator("Passwords didn't match.", lambda i:
i.password == i.password_again)]
)

As you can see, when you create a form you can pass an additional list
of which that can work on the form as whole (i.e. access all the
registered fields);  there shouldn't be too hard to adapt the previous
example to your specific use case.

Please, get back to us if you need further help.


Cheers,

Matteo


>
> --
> This message is confidential. It may also be privileged or otherwise
> protected by work product immunity or other legal rules. If you have
> received it by mistake please let me know by reply and then delete it from
> your system; you should not copy the message or disclose its contents to
> anyone.
>
> --
> You received this message because you are subscribed to the Google Groups
> "web.py" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to webpy+unsubscr...@googlegroups.com.
> To post to this group, send email to webpy@googlegroups.com.
> Visit this group at http://groups.google.com/group/webpy?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to webpy+unsubscr...@googlegroups.com.
To post to this group, send email to webpy@googlegroups.com.
Visit this group at http://groups.google.com/group/webpy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to