# Simple javascript question with enable/disable

**URL:** https://forum.kirupa.com/t/simple-javascript-question-with-enable-disable/233189
**Category:** Uncategorized
**Created:** [July 20, 2007, 10:32pm UTC](https://forum.kirupa.com/t/simple-javascript-question-with-enable-disable/233189 "2007-07-20T22:32:29Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![rondog](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/rondog/32/2478_2.png) [@rondog](https://forum.kirupa.com/u/rondog)
#### Post date: [July 20, 2007, 10:32pm UTC](https://forum.kirupa.com/t/simple-javascript-question-with-enable-disable/233189/1 "2007-07-20T22:32:29Z")

</div>

I have a login form and I simply want to disable the username, password and submit button until they check the “I have read the policy” checkbox.

Well I got the username field to be disabled, but the password and login btn are still enabled initially. If I check the box and then uncheck it then everything is disabled.

here is a link so you can see what I am talking about: [http://movfactory.com/datron](http://movfactory.com/datron)

Here is my javascript:

```php

/*datron form control */
function checkForm() {
if(document.form1.haveRead.checked == false) {
    document.form1.password.disabled = true;
    document.form1.username.disabled = true;
    document.form1.submitbtn.disabled = true;
    } else {
    document.form1.password.disabled = false;
    document.form1.username.disabled = false;
    document.form1.submitbtn.disabled = false;
    }
}

```

and my form HTML:

```php

<script src="datronform.js" type="text/javascript">checkForm();</script>
............other html crap...................
        <form id="form1" name="form1" method="post" action="<? echo $_SERVER['PHP_SELF']; ?>">
          <table width="200" border="0" cellspacing="0" cellpadding="5" align="center">
            <tr>
              <td><label>Username: </label></td>
              <td><input name="username" type="text" id="username" class="inputtxt" size="32"/></td>
            </tr>
            <tr>
              <td><label>Password: </label></td>
              <td><input name="password" type="password" id="password" class="inputtxt" size="32"/></td>
            </tr>
            <tr>
              <td colspan="2"><div align="right">
                  <input type="checkbox" name="haveRead" id="haveRead" onchange="checkForm()" />
              I have read the policy.</div></td>
              <td></td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td><div align="right">
                <input type="submit" name="Submit" value="Login" id="submitbtn" class="submitbtn" />
              </div></td>
            </tr>
          </table>
        </form>

```
