Link to home
Start Free TrialLog in
Avatar of garethtnash
garethtnashFlag for United Kingdom of Great Britain and Northern Ireland

asked on

JQuery Validate if CheckBox not Selected

Hello,

I'm a little bit stuck with this,

I have a form id = #BrandRate, on which I have the following -

checkbox #nextyear
Select List #nextyearreason

The #nextyearreason is required only if #nextyear is NOT checked...

So far I have (from here) --

<script>
$(".selector").validate({
   rules: {
     contact: {
       required: true,
       email: {
         depends: function(element) {
           return $("#nextyear").not(":checked")
         }
       }
     }
   }
})
</script>

Open in new window


I've not got very far I know! Also what if i need to add additional IDs that are required?

or different validation rules for different IDs?

Thanks
SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of garethtnash

ASKER

Thank you