surveyjs / survey-library

Free JavaScript form builder library with integration for React, Angular, Vue, jQuery, and Knockout.
https://surveyjs.io/form-library
MIT License
4.21k stars 813 forks source link

onValidatePanel event #9031

Open forat98 opened 3 days ago

forat98 commented 3 days ago

Describe the bug Hi, I'm using the onValidatePanel event to capture the error validation message in panel: onValidatePanel: EventBase<SurveyModel, ValidatePanelEvent>; However, I'm facing an issue where the event is being called twice at the same time, and I'm not sure why. Below is my code:

this.surveyModel.onValidatePanel.add((sender, options) => { console.log('options', options.panel); });

Steps to reproduce

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Please complete the following information:

Additional context Add any other context about the problem here.

JaneSjs commented 1 day ago

Hello @forat98, It appears that the survey.onValidatePanel event is being invoked for:

In the meantime, you can check the options.panel.getType() and validate options.panel when the type is "panel".

survey.onValidatePanel.add((sender, options) => { 
   if(options.panel.getType() === "panel"){
      // Validate a panel
       console.log('options', options.panel.name); 
    }
});

View Demo