Skip to content

Multi step form: make user selection required #780

Answered by NikRoe
AchimBartscht asked this question in Web
Discussion options

You must be logged in to vote

Hi there,

if you make the disabled attribute dependent on the selectedValue state, your form should work as intended.
You can get rid of your isChecked state and of the handleChange function as well.

The call of your StyledButton can look like this:

 <StyledButton
          type="button"
          disabled={selectedValue ? false : true}
          onClick={() => {
            handleNextButtonClick(questionData.topic, selectedValue);
            setSelectedValue(null);
          }}
        >
          next
        </StyledButton>

And for your StyledInput you want to change the onChange back to how it was this morning:

onChange={(event) => setSelectedValue(Number(event.target.value))}

The st…

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@AchimBartscht
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by NikRoe
Comment options

You must be logged in to vote
3 replies
@NikRoe
Comment options

@AchimBartscht
Comment options

@NikRoe
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Web
Labels
None yet
3 participants