On Feb 5, 6:09 am, Leonardo K <leo...@gmail.com> wrote:
> http://docs.jquery.com/Plugins/Validation/Methods/required#dependency...

Ok, here's my markup and my attempt to do the conditional validation,
but it obviously doesn't work.  I only want the select (#select) to be
required if the radio button (#accept) is clicked.


<div class="radio">
        <label class="error none" for="field_2"><a class="tooltip"
title="This field is required"></a></label>
        <label>RSVP</label>
        <input type="radio" name="field_2" id="accept"
validate="required:true" value="Accept" /><label class="radio
clearfix">Accept</label>
        <input type="radio" name="field_2" class="clear clearfix"
value="Regret" /><label class="radio">Regret</label>
        <div class="hide attendees">
                <label>Attendees</label>
                <select id="select" name="field_3">
                        <option value="">#</option>
                        <option value="1">1</option>
                        <option value="2">2</option>
                </select>
        </div>
</div>

        var r = jQuery("#rsvp").validate({
                rules: {
                        select: {
                                required: "#accept:checked"
                        }
                }
                submitHandler: function(form) {
                        jQuery(form).ajaxSubmit(options2);
                }
        });

Reply via email to