0

I don't want to ask this simple question here but this feature is not working for me and I don't understand why. Everything looks correct:


class Questionnaire extends Component {
  constructor(props) {
    super(props);
    this.state = {
      status: true,
    };
  }
  render() {
    return (
      <div disabled={this.state.status === true ? true : false}>
        <h1>The Form</h1>
        <input type="text" />
        <br />
        <input type="text" />
        <br />
        <input type="text" />
        <br />
        <input type="text" />
        <br />
        <button>Submit</button>
      </div>
    );
  }
}

export default Questionnaire;

Do you see something wrong here? Please point out my mistake. Also I've created this stackblitz.

Ahmet Emre Kilinc
  • 5,489
  • 12
  • 30
  • 42
Tanzeel
  • 4,174
  • 13
  • 57
  • 110

2 Answers2

1

Depending on what you want to achieve you can either set disabled on the entire form with a fieldset - How can I make an entire HTML form "readonly"?

or you can set disabled property to the submit button

Dmitriif
  • 2,020
  • 9
  • 20
0

You can wrap your div by fieldset instead. or use below CSS

div[disabled=disabled] {
pointer-events: none;
opacity: 0.4;
}

check this: How to disable all div content

Ahmed Hany
  • 952
  • 6
  • 12