I think I got it.. can someone validate this for me..see if I'm on the
right track?

rules: {
regType: {required: true},
first_name: {required:true},
last_name: {required:true},
individual_state: {
        required: function(element) {
        return $('input[name=regType]:checked').val() == 'Individual'
        }
},
business_state: {
        required: function(element) {
        return $('input[name=regType]:checked').val() != 'Individual'
        }
}

Thanks!


On Mar 14, 2:55 pm, Loony2nz <loony...@gmail.com> wrote:
> validation.
>
> basically if they choose individual, show the individual section of
> the form and make those fields validate (address, city, state, zip all
> required).
> but if they choose business don't make the individual section
> required.
>
> i'm lost how to do this logic in the jQuery validation plug in..
>
> thanx for your response.
>
> On Mar 14, 2:46 pm, "Rick Faircloth" <r...@whitestonemedia.com> wrote:
>
> > Is it "validation" you need, or just something to respond to their
> > choice in order to set up your page accordingly?
>
> > > -----Original Message-----
> > > From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
> > > Behalf Of Loony2nz
> > > Sent: Saturday, March 14, 2009 5:31 PM
> > > To: jQuery (English)
> > > Subject: [jQuery] [validate] Need example of dynamic validation
>
> > > Hi all,
>
> > > I need an example for this situation:
>
> > > I have a form that dynamically shows different parts of the form based
> > > on radio button choices.
>
> > > Example:  Registrion type:  Business or Individual radio buttons
>
> > > If they click on Business, I have a portion of the page only show
> > > business information fields.
> > > If they click on Individual, I have another portion of the page only
> > > show individual information fields.
>
> > > How can I validate, say, "business_state" or "individual_state" based
> > > on the radio button choice?
>
> > > If I put in validation in the function for both fields, I get no
> > > validation and the form passes.  But, if I put in one or the other
> > > validation the form does the validation and doesn't pass.
>
> > > help :(
>
> > > Thanks!
>
> > > No virus found in this incoming message.
> > > Checked by AVG -www.avg.com
> > > Version: 8.5.278 / Virus Database: 270.11.12/1998 - Release Date:
> > > 03/14/09 06:54:00

Reply via email to