Worked!
Thanks James.
I was so close before, and thought I was way off, but thanks to your
help...



On Sep 28, 7:22 pm, James <james.gp....@gmail.com> wrote:
> Sorry, here's a fix of the rules ('input' is suppose to be 'select')
> (these are untested):
>
> options = {
>     rules: {
>         mySelect: { required:true },
>         myfield1: {
>             required: function() {
>                 return ($("select[name=mySelect]").val() == '1');
>             }
>         },
>         myfield2: {
>             required: function() {
>                 return ($("select[name=mySelect]").val() == '1');
>             }
>         },
>         myfield3: {
>             required: function() {
>                 return ($("select[name=mySelect]").val() == '2');
>             }
>         },
>         myfield4: {
>             required: function() {
>                 return ($("select[name=mySelect]").val() == '2');
>             }
>         }
>     }
>
> }
>
> On Sep 28, 2:20 pm, James <james.gp....@gmail.com> wrote:
>
>
>
> > Suppose your fields look like this:
>
> > <select name="mySelect">
> >     <option value="1">Option 1</option>
> >     <option value="2">Option 2</option>
> > </select>
> > <input type="text" name="myField1" />
> > <input type="text" name="myField2" />
> > <input type="text" name="myField3" />
> > <input type="text" name="myField4" />
>
> > Your validation rules would look something like this:
>
> > options = {
> >     rules: {
> >         mySelect: { required:true },
> >         myfield1: {
> >             required: function() {
> >                 return ($("input[name=mySelect]").val() == '1');
> >             }
> >         },
> >         myfield2: {
> >             required: function() {
> >                 return ($("input[name=mySelect]").val() == '1');
> >             }
> >         },
> >         myfield3: {
> >             required: function() {
> >                 return ($("input[name=mySelect]").val() == '2');
> >             }
> >         },
> >         myfield4: {
> >             required: function() {
> >                 return ($("input[name=mySelect]").val() == '2');
> >             }
> >         },
> >     }
>
> > }
>
> > On Sep 28, 2:10 pm, Andrew <andrewgtibbe...@gmail.com> wrote:
>
> > > Info:
> > > - jquery-1.3.2
> > > - jquery.validate-1.5.5
> > > - form with 1 dropdown select and 4 text inputs
>
> > > Setup:
> > > - all 4 text fields are not initially required.
>
> > > Issue:
> > > The first input element is a required dropdown select.
> > > If the user selects option 1, then text field 1 & 2 need to be
> > > required.
> > > If the user selects option 2, then text field 3 & 4 need to be
> > > required.
>
> > > How do code this?
>
> > > Thanks in advance!
> > > Also, I tried searching the groups first but couldn't find anything
> > > that either worked are was close enough for me to tweak.

Reply via email to