Question T15442
Visible to All Users

BUG - The question is not removed the required when the condition question of this question is hidden

created a year ago

Hi SurveyJS team,

Please review and fix this bug:
Pre-condition:
There is a Form has the question1 with Required condition is the question 2, the question 2 with Visible condition is the question 3.
Screenshot 2023-11-08 at 14.18.11.png

Step:

  1. Input value for question3 to question2 is displayed
  2. Input value for question2 to question1 is required and Click "Complete"
  3. Continue update this Form
  4. Edit value of question 3 to question2 is hidden
  5. Observe question1

Video: Attached file
Expected: Question1 is removed the required
Actual result: Question1 is still the required

Thanks,

Answers approved by surveyjs Support

created a year ago

Hello,
By default, a survey doesn't clear values when questions become hidden. That is why question1 remains marked as required even though question2 gets hidden. If you wish to reset the isRequired flag for question1 once question2 gets hidden, set the SurveyModel's clearInvisibleValues property to "onHidden". Please test this sample:

JSON
{ "pages": [ { "name": "page1", "elements": [ { "type": "text", "name": "question1", "requiredIf": "{question2} = 123" }, { "type": "text", "name": "question2", "visibleIf": "{question3} = 123" }, { "type": "text", "name": "question3" } ] } ], "clearInvisibleValues": "onHidden" }

Let me know if you have any further questions.

Thanks

    Comments (1)
    SA SA
    SurveyJS Admin a year ago

      It's work for this case.

      Thank you,