Я думаю, что это должно работать:
if ($('input:radio[name=pic]:checked').length && $('#email').val().length && $('#comment').val().length) {
/* activate the lightbox link */
}
else {
alert("Please ensure you've selected one of the radio buttons, and filled out the text-fields.");
}
Отредактировано для изменения вашего кода:
html:
<form action="#" method="post">
<input type="radio" name="pic" id="pic" value="val1">
<input type="radio" name="pic" id="pic" value="val2">
<input type="radio" name="pic" id="pic" value="val3">
<input type="text" name="email" id="email" value="">
<input type="text" name="comment" id="comment" value="">
<input type="submit" value="submit" />
</form>
jQuery:
$('form').submit(
function() {
if ($('input:radio[name=pic]:checked').length && $('#email').val().length && $('#comment').val().length) { /* activate the lightbox link */
}
else {
alert("Please ensure you've selected one of the radio buttons, and filled out the text-fields.");
}
return false;
});
JS Fiddle demo .