Joy Acharya
Joy Acharya

Reputation: 680

Check Box Validation

enter image description here

In 'Leave Type' dropdown there are 3 fields casual leave, maternity leave. 1,2,3,4,5... these are the date fields , I have converted these fields into days.

I want to ensure that if 'Leave Type' selected index is 0 then I couldn't check the check box.

  function(LeaveTypeSelectedIndex,chk)
   {
      if(LeaveTypeSelectedIndex==0)
      {

         chk..checked = false;
      }
   }

I have tried but i'm not going to my destination. how do i do that. And Thanks in Advance

Upvotes: 1

Views: 127

Answers (2)

yamass
yamass

Reputation: 832

I think the way you try to uncheck the checkbox is the problem. See https://stackoverflow.com/a/17420580/524913 .

Basically, this is what you need to do:

$(chk).attr('checked', false);

Upvotes: 2

Yann Poiré
Yann Poiré

Reputation: 134

Not sure but you give no conditions to your if statement... and also I think you need it to be a variable...

function($LeaveTypeSelectedIndex,$chk) {
    if($LeaveTypeSelectedIndex==0) {
         $chk.checked = false;
    }
}

Upvotes: 1

Related Questions