Hi Stephen
Is there any way to change a fields ‘required’ attribute with Javascript? I’ve added a couple of fields that are hidden at page load and only appear once a certain condition is met. I’d like to make them required only if they are shown. Example:
We have an event that is normally attended by adults with children. However children can attend on their own if they have parental consent. So I’ve added a bit of jQuery that shown a consent tick box and parent name field if child tickets > 0 and parent tickets == 0. I want these fields to become required only if that condition is met.
Is there any way to achieve this?
Cheers
Stuart

Stuart Farish
You could listen for when the user makes a ticket selection and then add/remove the field. However, if it’s ‘required’ in the form customiser then the server-side checks will reject the booking unless its has been filled in. You could around this by not making it a required field and then adding additional checks when the server validates the booking.
(Here’s an example of additional validation checks – in particular the second section).

Stephen Harris
I should add that 1.6 is bringing it with a checkout (javascript) API. The idea is that you could listen for a change in the checkout ‘basket’ and act accordingly. In fact its already available, but being improved. The VAT and Discount Codes extension to calculate the appropriate VAT/discount and add a row to the booking cost table.

Stephen Harris