Thanks James I appreciate you replying.  I'm still having some
trouble, even with your additions.  I changed the checkbox to radio
buttons.  I added this code snippet to get the value of the checked
radio. Yes == 1 and No == 0, if the user selects No (0) then the
billling address fields need to be required. Does this make sense?

$("input.billing_addr_grp").click(function() {
  var billing_address = $("[name=billing_addr]:checked").val();
})

Then the rules:
$('#transaction').validate({
                rules: {
                        first: "required",
                        last: "required",
                        billing_first: {
                                required: function() { return billing_address 
== 0; }
                        },

                        billing_last: {
                                required: function() { return billing_address 
== 0; }
                        }

I still can't get them to only be required when the value of the radio
button is 0.  Any more thoughts?
Thanks,
MD

On May 14, 6:19 pm, James <james.gp....@gmail.com> wrote:
> Something like:
>
> rules: {
>      first: "required",
>      last: "required",
>      ......
>      billing_first: {
>           required: function() { return billing_address == 1; }
>      },
>      billing_last: {
>           required: function() { return billing_address == 1; }
>      },
>      billing_first: {
>           required: function() { return billing_address == 1; }
>      },
>      billing_address: {
>           required: function() { return billing_address == 1; }
>      },
>      .....
>
> },
>
> On May 14, 10:14 am, choffman <mountain....@gmail.com> wrote:
>
> > Hi There,
> > I could use some help here.  I need to place a conditionstatement
> > (if) in thisformvalidationscript.  For some reason, I just can't
> > get it to work.  Basically, when a user un-checks a particular box
> > (billing_addr) additionalformfields slide down, those fields need to
> > be validated.  Ifthe box is checked the fields roll-up, become
> > disable and can be skipped.  What's the best way to accomplish this?
>
> > Thanks,
> > MD
>
> > $(document).ready(function() {
> >         var billing_address = 
> > $("input[name='billing_addr']:!checked").val();
> >         $.metadata.setType("validate");
> >         $('#mysampleform').validate({
> >                 rules: {
> >                         first: "required",
> >                         last: "required",
> >                         address: "required",
> >                         city: "required",
> >                         state: "required",
> >                         country: "required",
> >                         zip: "required",
> >                         membertype: "required",
> >                         amount: "required",
> >                         state: "required",
> >                         mt: "required",
> >                         email: true,
>
> >                        if(billing_address == 1) {
> >                                 alert(billing_address);
> >                                 billing_first: "required",
> >                                 billing_last: "required",
> >                                 billing_address: "required",
> >                                 billing_city: "required",
> >                                 billing_state: "required",
> >                                 billing_zip: "required",
> >                                 billing_email: true
> >                         }
> >                 },
> >                 messages: {
> >                         first: "Please enter your first name",
> >                 }
> >         });
>
> > });

Reply via email to