question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Show errors on changing question value (optional)

See original GitHub issue

Hello. I have an issue that I hope you can help out with.

Are you requesting a feature, reporting a bug or ask a question?

Bug/question

What is the current behavior?

If I have a field that is invalid, i.e. it has an validation error on it, and I change the input text to something that I know is valid and then move the mouse to the Submit button without first clicking outside the given field, tabbing out or somehow lose focus of the field, OnValueChanged event is triggered but OnComplete is not.

Below are a series of images in which I try to explain the issue:

validation1

validation2

validation3

Not sure if necessary but below is the code we use for the two events:

container.on('KC.Web.Survey.OnValueChanged', function (event, sender, eventOptions) {
                        var questionHasErrors = eventOptions.question.hasErrors(true); // Check if question has errors and update UI accordingly

                        if (!questionHasErrors) {
                            // Save draft progress on value changed
                            var data = {
                                FormId: options.Form.Container.attr('data-id'),
                                SerializedInput: JSON.stringify(JS.Util.ReplaceIllegalCharacters(sender.data))
                            };
                            JS.Service.Post('External/Complaint/PersistFormInput', data);
                        }
                        //navigation(sender);
                    });

container.on('KC.Web.Survey.OnComplete', function (event, sender) {
                        var data = {
                            FormId: options.Form.Container.attr('data-id'),
                            SerializedInput: JSON.stringify(JS.Util.ReplaceIllegalCharacters(sender.data))
                        };

                        JS.Service.Post('External/Complaint/SubmitForm', data, function (response) {
                            JS.Global.HandleUrlResponse(response);
                        });
                    });

What is the expected behavior?

If I correct an invalid field and press the “Submit” button, without first triggering a OnValueChanged by changing focus out of the given field, I expect that the OnComplete event is triggered?

Kind regards, Nicklas

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
andrewtelnovcommented, Mar 23, 2018

@nicklas669 From the next minor version, you will be able to use the following code: survey.checkErrorsMode = "onValueChanged";

Unfortunately, it doesn’t fix the issue you are mention and what is more sad, I am afraid there is no way to fix it. I have spent couple hours trying to understand what’s going on, untill I have ended up with the following example. You may see that this example has nothing to do with surveyjs or any javascript framework. It is pure javascript and html. When you are entering more then 3 letters into input and click on the button, the div on top is hidden and the button onclick, simply is not fired. Same happens in our library, next page or survey complete buttons click simply are not fired 😉

Probably it is the expected behavior, I have checked several browsers.

Thank you, Andrew

0reactions
tsv2013commented, May 29, 2018

@mstoecke It was discussed in this thread - https://github.com/surveyjs/surveyjs/issues/1062 Here is the sample of the “validation on change” - https://plnkr.co/edit/ZNJ6TfOvHxLsquIXfmpY?p=preview

Read more comments on GitHub >

github_iconTop Results From Across the Web

Joi: Cannot change error message for an optional array where ...
I have a form for a project where the description is required, and if they want to add details, those textareas need to...
Read more >
How to correct a #VALUE! error - Microsoft Support
Excel shows the #VALUE! error when your formula includes cells that have different data types (text and numeric values). The #VALUE! error is...
Read more >
Formatting Answer Choices - Qualtrics
a multiple choice question with answer choices from "strongly agree" to "strongly disagree. Show first and last: Select this option to insert the...
Read more >
Excel VBA Error Handling - All You Need to Know!
In case it finds an error, it will show you a dialog box with the error. It finds errors one by one. So...
Read more >
Regrade a quiz after changing a question | Online Learning at ...
___ points. You need to “redo this step after saving to give credit for each option.”For example: if an old multiple-choice question answer...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found