eZ Community » Forums » Setup & design » Conditional form validation

Conditional form validation

Conditional form validation

Tuesday 26 September 2006 12:59:12 pm - 3 replies

Hi there

I have a form where the user can select between different payment options, e.g. cheque, paypal or credit card. If he selects credit card the fields for card holder, card number, expiry date ... must be filled in as well, otherwise they can be empty.

Is there a way to do this with the EZ form validation? Or can I somehow set up the class definition in such a way that the fields for the credit card details are only required if the option credit card is selected? I am using EZ 3.8.4.

Thanks for any tips


Tuesday 26 September 2006 3:36:44 pm


Just to be sure: you are storing credit cards info on ez publish or is this an exemple ?

Nothing native. You can create a custom template for the edit and add your business rules in the javascript onsubmit.

If this isn't only ergo/cosmetic, you will have to create a custom event that you'll add in the pre publish workflow to enforce your business rules.

Developing a custom event isn't really difficult, but debuging is a serious pain in the ... good luck and keep us inform !


Tuesday 26 September 2006 4:56:33 pm

Hi Xavier

Thanks for the answer - I was afraid that there was nothing built in for this but it never hurts to ask. As I do not know much about workflow syet I think I will just post the form to an (yet to write) extension of mine which performs the required validation (Javascript is not sufficient in this case) and then does the publishing.
Regarding the credit card info - it was more of an example. After reading a bit about it I know that this is nothing I would want to do. Another example for conditional validation would be e.g to force the customer to state either his phone number or his fax number - if he has given one I don't need the other.

Greetings from Luxembourg


Tuesday 26 September 2006 5:13:26 pm


I didn't want to scare you with the workflows, just warn you to not underestimate the debug time blunk.gif Emoticon

As for the extension, it looks like a good idea. Instead of writing a new one, I'd suggest you to have a look at powercontent from kristof. I don't think it'd be too complicated to add custom validations on his work.

If you want, contact us by email (ez at sydesy dot com ) so we can dig that a wee bit more.



You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from