I have a checkbox "CR". If it is checked it opens up a div which contains 2 radio buttons("IA" and "FA"). Now, if the user checks "CR" but does not select at least one radio, it should throw an alert that "At least one must be selected."
In my case, The alert pops up even if one of the radio button is checked. I am guessing I am missing on something very minute but couldn't figure out.
Below is the code:
<input type="checkbox" name="my_cr" id="CR"/>CR
<input type="radio" id="IA" name="Initial" />IA
<input type="radio" id="FA" name="Final" />FA
<input type="submit" />
if((!this.IA.checked) || (!this.FA.checked))
alert("Choose the approver type");
Your or (
||) should be an and (
Right now, if either is unchecked, the alert pops up.