Default checked checkbox not toggling on click

I am using Reactjs. I am working on creating a Modal form using Modal from react-bootstrap. I created a form using bootstrap. The form contains the checkbox that needs to be checked by default. So I used the checked property for the input checkbox. But the checkbox doesn’t toggle when I click on it. I can’t quite figure out the problem. Here is my code:

<Modal show={this.state.showModal} onHide={this.closeModal}>
<Modal.Header closeButton>
    <Modal.Title>Create New User</Modal.Title>
</Modal.Header>
<Modal.Body>

    <form class="form-horizontal" name="newUser">
        <div class="form-group">
            <label class="control-label col-md-4" for="userName">User Name</label>
            <div class="col-md-6">
                <input type="text" class="form-control" id="userName" ref="userName" placeholder="User Name"/>
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-md-4" for="password">Password</label>
            <div class="col-md-6">
                <input type="password" class="form-control" id="password" ref="password" placeholder="Enter Password"/>
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-md-4" for="password">Confirm Password</label>
            <div class="col-md-6">
                <input type="password" class="form-control" id="confirmPassword" ref="password" placeholder="Re-enter Password"/>
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-md-4" for="email">Email Address</label>
            <div class="col-md-6">
                <input type="email" class="form-control" id="email" ref="email" placeholder="Email Address"/>
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-offset-4 col-md-6">
                <div class="checkbox-inline">
                    <label><input type="checkbox" id="enabled" ref="enabled" value="enabled" checked/> Enabled </label>
                </div>
                <div class="checkbox-inline">
                    <label><input type="checkbox" id="locked" ref="locked" value="locked" /> Locked </label>
                </div>
            </div>
        </div>
    </form>
</Modal.Body>
<Modal.Footer>
    <Button onClick={this.submitUser} bsStyle="primary">Confirm</Button>
    <Button onClick={this.closeModal} bsStyle="warning">Cancel</Button>
</Modal.Footer>
</Modal>

Here is Modal Image. Thanks for help in advance.

148 thoughts on “Default checked checkbox not toggling on click”

Leave a Comment