Question T15141
Visible to All Users

Page level enableIf/ visible logic working on runtime

created a year ago (modified a year ago)

Hello,
I've designed a form that comprises two pages. The logic for each page is as follows: If question 1 is left empty, the first page remains enabled; however, when question 1 is filled, first page is disabled and the second page becomes visible.
We've encountered an issue where, during the form-filling process, if we inadvertently fill out question 1 first, the entire page becomes disabled, preventing us from filling out other questions. Additionally, the second page becomes visible prematurely.
Is there a way to ensure this logic functions correctly both during the initial completion of the form and when editing it later?
The Json for the form is -

JSON
{ "title": "Role form", "description": "Enter a form description", "pages": [ { "name": "page1", "elements": [ { "type": "signaturepad", "name": "question1", "title": "Signature" }, { "type": "text", "name": "question2", "title": "Your name" }, { "type": "text", "name": "question5", "title": "Date", "inputType": "date" } ], "enableIf": "{question1} empty" }, { "name": "page2", "elements": [ { "type": "text", "name": "question3", "title": "Where do you work?" }, { "type": "text", "name": "question4", "title": "What is your role?" } ], "visibleIf": "{question1} notempty" } ] }

Answers approved by surveyjs Support

created a year ago

Hello,
Your "question1" is inside "page1". You will need to put all other questions in "page1" inside a panel and move "enableIf": "{question1} empty" inside this panel. In this case a user can clear question1 value or put values and based on this all questions inside the panel will become enable/disable. You can use the panel as a container only, without any title.

Thank you,
Andrew
SurveyJS Team

    Comments (2)

      Hi,
      I tried panel thing, and still the logic is working while filling the form.

      what I want-
      So, while filling the new form, the logic should not work, i.e, if question 1 is filled, other fields should still be editable. After completing the form and opening the filled form, then the logic should work, i.e, then it should make the fields disabled.

      Is there any way I can do this?

      AT AT
      Andrew Telnov a year ago

        Hello,
        You can have an a variable with a name, for example, "isNotCompleted". You can set survey.setVariable("isNotCompleted", true); initially and for completed surveys survey.setVariable("isNotCompleted", false); and then your expression will be:
        "enableIf": "{question1} empty or {isNotCompleted}".

        Thank you,
        Andrew
        SurveyJS Team