title: disable textbox using javascript
body: <p>As the title says, i am, trying to disable textbox when i open the file</p>
  <pre><code>&lt;form name='registration' action=&quot;registration.php&quot; method=&quot;post&quot; onSubmit=&quot;return formValidation();&quot;&gt;
      &lt;table&gt;
          &lt;tr&gt;
              &lt;td&gt;FirstName:&lt;/td&gt;     
              &lt;td&gt;&lt;input type = &quot;Text&quot; name = &quot;firstname&quot; id=&quot;1&quot;&gt;&lt;/p&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/form&gt;
  </code></pre>
  <p>and I try ti disable it using the following javascript code:</p>
  <pre><code>function formValidation() {
      var fn = document.registration.firstname;
      if(fname_validation(fn)) {}
      document.getElementById(&quot;1&quot;).disabled = true;
  }
  
  function fname_validation(fn) {
      var fn_len = fn.value.length;
      var fn_char = /^[A-Za-z]+$/;
      if (fn_len == 0) {
          alert(&quot;first name cannot empty&quot;);
          return false;
      }
      if (!fn.value.match(fn_char)) {
          alert(&quot;first name must enter alphabet only&quot;);
          return false;
      } else {
          return true;
      }
  }
  </code></pre>
  <p>Why the text box still does not disable?</p>