title: How to disable input unless a radio button is clicked?
body: <p>I'm not so familiar with Javascript and I know this to be a very easy question, but I can't figure out where I'm going wrong.</p>
  
  <p>I'm trying to disable two input fields unless a radio button with the id "custom" is selected.</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;input type="radio" name="period" value="week" /&gt; Weekly
  &lt;input type="radio" name="period" value="fortnight" /&gt; Fortnightly
  &lt;input type="radio" name="period" value="month" /&gt; Monthly
  &lt;input type="radio" name="period" value="quarter" /&gt; Quarterly
  &lt;input type="radio" name="period" value="year" /&gt; Annually
  &lt;input type="radio" name="period" id="custom" value="one-time" onchange="datedis()"/
  &lt;input type="date" name="from" disabled /&gt; to &lt;input type="date" name="to" disabled /&gt;
  </code></pre>
  
  <p><strong>Javascript</strong></p>
  
  <pre><code>function datedis() {
      if(document.getElementsById("custom").checked) {
          document.getElementsByName("from").disabled = false;
          document.getElementsByName("to").disabled = false;
      } else {
          document.getElementsByName("from").disabled = true;
          document.getElementsByName("to").disabled = true;
      }
  }
  </code></pre>
  
  <p><a href="http://jsfiddle.net/54YGT/" rel="nofollow">Here</a> is my code in JSFiddle.</p>