title: How to identify whether or not a radio has been checked programmatically?
body: <p>I have a form page in which the user can enter an ID, and the corresponding profile data is pulled from mysql and displayed in the form so that the user may edit it. </p>
  
  <p>One element is a group of radios, so you may select a year level (ie "1", "2", "3", etc). </p>
  
  <p>When a user provides an ID, an AJAX call is made to pre-populate the form with data, including selecting the appropriate radio.</p>
  
  <p><strong>problem:</strong></p>
  
  <p>The user must select a year level to submit the form. I check this with a <code>verifyForm()</code> method:</p>
  
  <pre><code>function verifyForm() {
      if( !document.addStudentForm.elements["yearLevel"].checked ) {
          alert( "You must select a year level before submitting." );
          return false;
      }
  };
  </code></pre>
  
  <p>I expect this to check <code>yearLevel</code> and, if an option isn't selected, alert/return false.</p>
  
  <p>However, when the <code>yearLevel</code> radio is pre-selected by the AJAX data, this is still behaving as if the user did not select a radio.</p>
  
  <p>The radio is populated by js via the following code:</p>
  
  <p><code>document.getElementById( "yearLevel_&lt;?=$student['student']-&gt;get('yearLevel')?&gt;" ).checked = true;</code></p>
  
  <p>edit: Here is the relevant HTML.</p>
  
  <pre><code>&lt;form name="addStudentForm" action="validation/updateStudentValidate.php" method="POST" onSubmit="return verifyForm()"&gt;                                 
      &lt;input type="radio" value="1" name="yearLevel" disabled id="yearLevel_1" /&gt; 1
      &lt;input type="radio" value="2" name="yearLevel" disabled id="yearLevel_2" /&gt; 2
      &lt;input type="radio" value="3" name="yearLevel" disabled id="yearLevel_3" /&gt; 3
      &lt;input type="radio" value="4" name="yearLevel" disabled id="yearLevel_4" /&gt; 4
      &lt;input type="radio" value="5" name="yearLevel" disabled id="yearLevel_5" /&gt; 5
      &lt;input type="radio" value="6" name="yearLevel" disabled id="yearLevel_6" /&gt; 6
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>Question:</strong></p>
  
  <p>How can I have my javascript properly identify whether or not the radio has been checked, regardless of if it was selected by hand or programmatically? </p>