Complex server-side rules with QuickForm

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Hi All,

I am wanting to do "complex" server-side JS validation.  I put "complex" in
quotes because complex is of course in the eye of the beholder.

What I would like to do is actually fairly simple in theory.  We have a drop
down box, and a text box.  We ask the user for their favorite color, and the
options in the drop down box are red, green, blue, or other.  If they choose
red, green, or blue, then the text box is grayed out (disabled='disabled'
attribute is set for the <input> tag).  If they choose other, then the text
box becomes available for them to input their favorite color in.

Is there a way to do this with QuickForm without resorting to hand-coding
all the JS?  I have a vague sense that I once saw a tutorial on how to do
this, but I've been googling for it and not been able to turn anything up.
I would be very grateful for any tips!


Re: Complex server-side rules with QuickForm

I am not familiar with QuickForms but it sounds like you require a
JavaScript solution.

This would then be a client side action.  If you are trying to avoid
using a scripting language then I am not sure if it is possible the way
you describe.

You could get them to choose and submit and check if it is other, and
if so on the next page ask them for input as to what it is.

Alternatively you could give them an enabled <input> text box in case
they choose other and only read this value if they have chosen other.
Else just use the value in the drop down menu.

Hope this is clear for you and that it helps.

Re: Complex server-side rules with QuickForm

I said server side when I meant client side - obviously the JS for this
needs to be client side.

Site Timeline