I am making a form with switches in it. I can check all other input except the switch. I got an acceptable solution for this on this site.
Using jQuery to check if a switch is set in a group
but it does not work for me
http://jsfiddle.net/ghan_123/trr185L2/2/
my code
<input type='radio' name='datetime' value='1'>1 <input type='radio' name='datetime' value='2'>2 <input type='radio' name='datetime' value='3'>3 <input type='radio' name='datetime' value='4'>4 <input type='radio' name='datetime' value='5'>5 <br><button id='buttonnew'>validate</button>
JQuery
$(document).ready(function(){ $("#buttonnew").click(function(){ var selection=document.querySelector('input[name="datetime"]:checked').value;
when nothing is checked, a warning message does not appear. otherwise, both give a warning message to select one of them.
source share