title: Javascript ES6 Syntax Radio button check
body: <p>I have been trying to convert my code using the ES6 syntax and wondering why are my form's radio and checked buttons not registering as true when check. I still get the error message even if a user selects one of the choices? Could you please help me with what I'm doing wrong so I can better understand.</p>
  <pre class="lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
      &lt;title&gt;Validate me&lt;/title&gt;
      &lt;script type=&quot;text/javascript&quot;&gt;
              validateAll =()=&gt; {
              var formdata = document.forms[0].elements;
              var numelems = formdata.length;
              var checkboxelem = false;
              var radioelem = false;
              var msg = '';
              var radmsg = '';
              var checkmsg = '';
              var textmsg = '';
              var checker = true;
              for (let i = 0;i&lt;numelems;i++){
                  if (formdata[i].type == 'text' &amp;&amp; formdata[i].value === ''){
                      msg += &quot;&lt;br&gt;please enter your &quot; + formdata[i].name;
                      checker = false;
                  }
  
                  if (formdata[i].type == 'radio'){
                      radname = formdata[i].name;
                      const numelems = document.getElementsByName(radname).length;
                      for (let rad=0;rad&lt;numelems; rad++) {
                          if (radname[rad].checked === true){
                              radioelem = true;
                          }
                      }
                      if (radioelem === false){
                          radmsg = &quot;&lt;br&gt;please select a &quot; + radname;
                          checker = false;
                      }
                  }
  
                  if (formdata[i].type == 'checkbox'){
                      grpname = formdata[i].name;
                      const numelems = document.getElementsByName(grpname).length;
                      for (let chk=0;chk&lt;numelems; chk++) {
                          if (grpname[chk].checked === true){
                              checkboxelem = true;
                          }
                      }
                      if (checkboxelem === false){
                          checkmsg = &quot;&lt;br&gt;please check a &quot; + grpname;
                          checker = false;
                      }
                  }
  
                  if (formdata[i].type == 'select-one' &amp;&amp; formdata[i].value === ''){
                      msg += &quot;&lt;br&gt;please select your &quot; + formdata[i].name;
                      checker = false;
                  }
  
                  if (formdata[i].type == 'textarea' &amp;&amp; formdata[i].value === ''){
                      textmsg += &quot;&lt;br&gt;please enter your &quot; + formdata[i].name;
                      checker = false;
                  }
  
              }
  
              document.getElementById('err').innerHTML = msg + radmsg + checkmsg + textmsg;
              return checker;
          }
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      At lease one piece of data has to come in from every input type.&lt;br&gt;&lt;br&gt;
      &lt;span id = &quot;err&quot;&gt;&lt;/span&gt;
      &lt;form action = &quot;dynamic.html&quot; method = &quot;post&quot; onsubmit=&quot;return validateAll();&quot; &gt;&lt;br/&gt;
          Name:&lt;input type = &quot;text&quot; name = &quot;fullname&quot; placeholder=&quot;Enter Full Name&quot;/&gt;&lt;br/&gt;
          Gender:&lt;br/&gt;
          Male&lt;input type = &quot;radio&quot; name = &quot;gender&quot; value=&quot;male&quot;/&gt;Female&lt;input type = &quot;radio&quot; name = &quot;gender&quot; value=&quot;female&quot;/&gt;&lt;br/&gt;
          Hobbies &lt;br/&gt;
          Baseball &lt;input type = &quot;checkbox&quot; name = &quot;hobbies[]&quot; value = &quot;baseball&quot; /&gt;  
          Football &lt;input type = &quot;checkbox&quot; name = &quot;hobbies[]&quot; value = &quot;football&quot; /&gt;  
          Hockey &lt;input type = &quot;checkbox&quot; name = &quot;hobbies[]&quot; value = &quot;hockey&quot; /&gt;&lt;br/&gt;
          Favorite Show &lt;select name = &quot;show&quot;&gt;
          &lt;option value = &quot;&quot;&gt;Choose Below&lt;/option&gt;
          &lt;option value = &quot;ATHF&quot;&gt;Aqua Teen Hunger Force&lt;/option&gt;
          &lt;option value = &quot;Family Guy&quot;&gt;Family Guy&lt;/option&gt;
          &lt;option value = &quot;Simpsons&quot;&gt;Simpsons&lt;/option&gt;
      &lt;/select&gt;&lt;br/&gt;
      Comments&lt;br/&gt;
      &lt;textarea cols = &quot;50&quot; rows = &quot;6&quot; name = &quot;comments&quot;&gt;&lt;/textarea&gt;&lt;br/&gt;
      &lt;input type = &quot;submit&quot; name = &quot;submit&quot; value = &quot;enter me&quot; /&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>