Good day! There is a conditional form with two radiobuttons and a submission:
<form> <input type="radio" name="radio" value="1" id="one" /> <input type="radio" name="radio" value="2" id="two" /> <input type="submit" id="submit" /> </form> There are no options to select, the form will not be submitted:
if($('input[name=radio]').attr('checked') != 'checked')) { alert('Вы не сделали выбор'); return false; } But with the sending form when choosing one or another option, problems arose. Tried to hang handlers on click:
$('#one').click(function() { $('#one').attr('checked', true); }); $('#two').click(function() { $('#two').attr('checked', true); }); But only #one fulfills, and when #two is selected, the alert is output again. How to be?