PDA

View Full Version : conditional validation


watercolor346374
12-04-2009, 09:59 AM
Hi,
I have read docs for valadation tool kit and css forms. Still not getting how to do the following:
When a customer chooses New York state they are required to choose a county, which is list/menu located in the next table row. I know this is conditional, but do not know how to implement.
Thank you

Eric Mittman
12-07-2009, 11:42 AM
The part of this that makes it difficult to apply the conditional validation is that the selected value comes from a select list. Since you are trying to validate a select list you will only have two client side validations available that you can use to trigger the conditional validation response. The two that are available are required, which won't work here since all of the choices in the state select list have a value associated with them, and regular expression. This one is probably the best fit, but you will need to come up with a regular expression to match for the NY selection.

You can then use this validation as the trigger for the conditional validation on the county select list.

watercolor346374
12-07-2009, 12:27 PM
What if I had a required check box and it asked are you a new york resident? they would check yes or no. If they check yes, the drop down for the cities and counties would show up. If that were the case would that be server side conditional?

Eric Mittman
12-07-2009, 05:44 PM
That is an excellent alternative. If you had it setup like this it would still be a client side conditional validation, but you could just use the required/not blank validation on this checkbox. You would then apply the conditional validation and refer to this checkbox for the triggering element. Once you have this pair of client validations you would put in your others validations like normal.

watercolor346374
12-10-2009, 10:04 AM
Hi Eric,
I just need some clarification using the check box method of validation:
My dilemma is: I have placed the two checkboxes (no for not NY resident and Yes if NY resident in the same table row. As I was running through the validations I noticed that each checkbox came up separatly for validation. Therefore I would have validation for each and this defeats my purpose. How can I make it so that they can check either or. So if one is blank and one is checked they get no message, but if one is checked it is ok. And then if the NY is checked I follow the recipe used for tell a friend?
Thank you

Eric Mittman
12-10-2009, 01:25 PM
To get the conditional validation working like this you will need to first apply the required validation to the yes checkbox. Next you would apply the conditional validation. For the trigger you would choose the yes checkbox, for the target you would choose your county select list. You would then say if trigger is valid then validate the target element.