Checking empty form elements in javascript
<p>I'm making a simple client-side, self-grading quiz. </p>

<p>I ask 6 questions and I want to alert the user with their score (keeping things simple).  If they leave an answer blank, an alert will appear.  </p>

<p>I'm new to javascript and don't really know how to check individual form elements to see if they're empty. I'm also having problems with getting my code to run.  </p>

<p><strong>JS</strong></p>

<p><em><strong>EDIT</em></strong></p>

<pre><code>function grade() {
    var score = 0;
    var elt = document.quiz;

    // Check to see if no questions were left unanswered.
    if elt.question1.value.length == 0 || elt.question2.value.length == 0 ||   
       elt.question3.value.length == 0 || elt.question4.value.length == 0 ||
       elt.question5.value.length == 0 || elt.question6.value.length == 0
      {
        alert ("Whoops, you're missing an answer!")
    }

    if (elt.question1[1].checked) {
        score += 1;
    }
    if (elt.question2[0].checked) {
        score += 1;
    }
    if (elt.question3[0].checked == false &amp;&amp; elt.question3[1].checked &amp;&amp;  
        elt.question3[2].checked == false &amp;&amp; elt.question3[3].checked == false) {
        score += 1;
    }
    if (elt.question4[0].checked == false &amp;&amp; elt.question4[1].checked == false &amp;&amp;
        elt.question4[2].checked == false &amp;&amp; elt.question4[3].checked) {
        score += 1;
    }
    elt.question5 = elt.question5.toLowerCase()
    if (elt.question5.value != '' &amp;&amp; elt.question5.value.indexOf('galaxy') != -1) {
        score += 1;
    }
    elt.question6 = elt.question6.toLowerCase()
    if (elt.question5.value != '' &amp;&amp; elt.question6.value.indexOf('age') != -1) {
        score += 1;
    }

    score = score / 6 * 100;
    score = score.toFixed(2);
    alert("You scored " + score + "%");

    return false; // Return true if you want the form to submit on validation/grade
}
</code></pre>
