Check Input text if empty based upon radio button selected
<p>I have two radiobuttons in a group on my page. Based upon radiobutton selected i want to generate an alert.</p>

<pre><code>var d=GetVal();

function GetVal()
{
var a = null;
var f = document.forms[0];
var e = f.elements["radiogroup"];

for (var i=0; i &lt; e.length; i++)
{
if (e[i].checked)
{
a = e[i].value;
break;
}
}
return a;
}
</code></pre>

<p>At the time of form validation, It is always returning only first radiobutton value when iam reading it in if else loop.</p>

<pre><code>if (!checkRadio("form","radiogroup")) 
{
alert("none of the option was selected"); 
return false;
}
//if one radio option was selected
else
{
if(d="firstradiovalue"){
alert("first radio selected");
return false;}
else{
if(d="secondradiovalue"){
alert("second radio Selected");
return false;}
}
}
</code></pre>

<p>At the time of form submission, even if i choose second option i only get alert - "first radio selected". Any help. Thx in advance.</p>
