Question T6801
Visible to All Users

is there anyway to display an error message that are not bundled with a question?

created 4 years ago

Hi. I have page which contains a few panels. I need to display an error message on top of all the panels when clicking continuing button.

thanks
Kelly

Answers approved by surveyjs Support

created 4 years ago

Hello Kelly,
You can't display error on the top of all panel, unless you add an html question, set to its "html" property your error message and set its visibleIf property to the appropriate expression.
You can show error in the Panel. You can use survey.onValidatePanel event for this or use panel.errors array and functions related to errors mechanism, for example panel.isRequried.

Thank you,
Andrew
SurveyJS Team

    Comments (2)

      Hi. Andrew

      We figured it a way to show error message. we set this html element with "display:none" on div class when page is loaded initially. When continue/complete button is clicked, we validate the data and change the div class.

      however, we want to remove this page level error message if there are other validation errors from expression. Is there any method/event that we can use after the expression validation is done to change div class on this html element for error message. I tried surveyModel.onAfterRenderPage. it does seem that this event is triggered when there is validation error from expression.

      Thanks
      Kelly

        You can simply put html question as I wrote and set visibleIf property for it. If this question is visible you may disable to go to the next page by using survey.onCurrentPageChanging.

        Another trick. You can add panel on the top, drop an html question into it and do not set anything into this question. The panel will be visible, since there a visible question in it, empty html question. Then using survey.onValidatePanel event, show error to this top panel when you need. It will prevent survey to go to the next page or complete it.

        Thank you,
        Andrew
        SurveyJS Team