Как проверить значение value с переданным значением

У меня есть данный кусок кода. У меня есть 9 input'ов, мне нужно, чтобы при submit'e происходила проверка, если value = переданному значению datavalue, то тогда в консоль выводится текст.

handleChange(event) {
        const { target: { name, value } } = event;
        this.setState({
          [name]: value,
        })
      }

      handleSubmit(e) {
        e.preventDefault();

        const {
          datavalue,
        } = this.props;

        const {
          number,
        } = this.state;

        if (number.value === datavalue) {
          console.log('все верно!');
          return true;
        }

        return false;
      }

Вот такая форма

<form className="home-page__form" onChange={onChange} onSubmit={onSubmit}>

        <InputCase datavalue="5" name="number" id="number" />
        <TextCase caption=":" />
        <InputCase />
        <TextCase caption="*" />
        <InputCase />
        <TextCase caption="= 14" />

        <TextCase caption="*" />
        <TextCase />
        <TextCase caption="-" />
        <TextCase />
        <TextCase caption="+" />
        <TextCase />

        <InputCase />
        <TextCase caption="+" />
        <InputCase />
        <TextCase caption="-" />
        <InputCase />
        <TextCase caption="= 5" />

        <TextCase caption="+" />
        <TextCase />
        <TextCase caption="+" />
        <TextCase />
        <TextCase caption="*" />
        <TextCase />

        <InputCase />
        <TextCase caption="-" />
        <InputCase />
        <TextCase caption="+" />
        <InputCase />
        <TextCase caption="= 6" />

        <TextCase caption="= 15" />
        <TextCase />
        <TextCase caption="= 0" />
        <TextCase />
        <TextCase caption="= 15" />
        <TextCase />

        <button type="submit">
          Отправить
        </button>
      </form>

введите сюда описание изображения

Оценю любую вашу помощь, подскажите пожалуйста, в чем проблема моего кода?


Ответы (0 шт):