Validating radio buttons by their boolean values?
<p>I want to avoid using a <code>for</code> loop to validate a set of radio buttons. I know that its possible to use their boolean value to do this I just cannot seem to execute it. Is there a better way to do this?</p>

<p>Here are my buttons: </p>

<pre><code> &lt;form method="post" name="newUser" onsubmit="return proc()"&gt;
            First name:&lt;br /&gt;
            &lt;input type="text" id="fName" /&gt;&lt;br /&gt;
            &lt;div id="first_name_error"&gt;&lt;/div&gt;
            Last name:&lt;br /&gt;
            &lt;input type="text" name="lName" /&gt;&lt;br /&gt;
            &lt;div id="last_name_error"&gt;&lt;/div&gt;
            E-mail address:&lt;br /&gt;
            &lt;input type="text" name="eMail" /&gt;&lt;br /&gt;
            &lt;div id="email_error"&gt;&lt;/div&gt;
            Gender:&lt;input type="radio" name"sex" value="male" /&gt;Male
                    &lt;input type="radio" name="sex" value="female" /&gt;Female&lt;br /&gt;
                     &lt;div id="gender_error"&gt;&lt;/div&gt;
</code></pre>

<p>Here is my JS:</p>

<pre><code>function proc(){
    var errmsg = "";
    if (document.forms["newUser"]["fName"].value == "")
    {
        document.getElementById('first_name_error').innerHTML = "*This field is required";
        document.getElementById('first_name_error').style.color = "red";
    }
    if (document.forms["newUser"]["lName"].value == "")
    {
        document.getElementById('last_name_error').innerHTML = "*This field is required";
        document.getElementById('last_name_error').style.color = "red";
    }
    if (document.forms["newUser"]["eMail"].value == "")
    {
        document.getElementById('email_error').innerHTML = "*This field is required";
        document.getElementById('email_error').style.color = "red";
    }
    if (document.forms["newUser"].sex == false)
    {
        document.getElementById('gender_error').innerHTML = "*Please select gender";
        document.getElementById('gender_error').style.color = "red";

    }

    return false;

}
</code></pre>
