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 Kılınç
  • 2,589
  • 4
  • 19
  • 33
Tanzeel
  • 3,044
  • 6
  • 31
  • 73

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
  • 1,154
  • 4
  • 16
1

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
  • 850
  • 5
  • 12