Witam
Podłącze się pod wątek.
Mam formularz, który sprawdza wszystkie radio w formularzu. A ja chce tylko wybrane.
function checkRadio() {
var inputs = document.getElementById('fo2').getElementsByTagName('input');
var noneChecked = true;
for(var i = 0; i < inputs.length; i++) {
if(inputs[i].type != 'radio') continue;
if(inputs[i].checked) {
noneChecked = false;
break;
}
}
if(noneChecked) {alert('Nie zaznaczono żadnego radio!');}
return false;
}
<form method="post" id="fo2" onsubmit="return checkRadio();">
for($x=0;x<=$ile;$x++)
{<input type="radio" name="r1" value="0"/> aaa}
<br />
<input type="radio" name="r2" value="0"/> Opcja 1
<input type="radio" name="r2" value="0"/> Opcja 2
<input type="radio" name="r2" value="0"/> Opcja 3
<input type="submit" value="Wyślij"/>
Chce żeby skrypt sprawdzał tylko pole name=r1. Bo tylko to jest wymagane, r2 może być puste.