<form name="frmOrnek"> <input type="radio" name="dogru_cevap" value="1" /> 1<br /> <input type="radio" name="dogru_cevap" value="2" /> 2<br /> <input type="radio" name="dogru_cevap" value="3" /> 3<br /> <input type="radio" name="dogru_cevap" value="4" /> 4<br /> <input type="radio" name="dogru_cevap" value="5" /> 5<br /> <input type="radio" name="dogru_cevap" value="6" /> 6<br /> <input type="submit" value="Testi Ekle" onclick="javascript:return fnFormGonder();" /> </form>
Çalışmamıza ait HTML kısmı bitti. JavaScript kısmını hazırlayalım.
Örnek Çalışma JavaScript
<script>
function fnFormGonder()
{
var dogru_cevap_secili = false;
for(i=0;i<this.frmOrnek.dogru_cevap.length;i++)
{
if(this.frmOrnek.dogru_cevap[i].checked)
{
dogru_cevap_secili = true;
}
}
if (!dogru_cevap_secili)
{
alert('Lütfen doğru cevabı belirtiniz!');
return false;
}
else
{
this.frmOrnek.submit();
this.disabled=true;
}
}
</script>