Hi,
I have two custom components where the change of one affects the validation of the other (logic and error message).
I'm using an ExpressionValidator
to call a pre-registered custom validation-function (only dummy in example).
So in the onValueChanged
of myLimitChoices
the validators of the validatedText
-question will always be set new and dynamically.
The validation works, the dynamic error-message is shown, but the question is not highlighted as error. Also the aria-invalid
-attribute stays false
.
Here is my example: https://codesandbox.io/s/snowy-smoke-gvwh64?file=/src/SurveyCreatorComponent.jsx
To test: set the dropdown to some value, add text to the text-question and submit.
Hello Mario,
Thank you for sharing a demo. We may need additional time to research it. Please stay tuned.
Hello Mario,
Please accept my apologies for the delayed reply. Would it be possible to update the code and configure validators at the level of your
validatedText
question? With this option, you can register a custom expression validator and within the custom validation function, check required values.ComponentCollection.Instance.add({ name: "validatedText", title: "Validated-Text", questionJSON: { type: "text", name: "validatedText", title: "Validated-Text", validators: [ { type: "expression", expression: "isValidFunction({validatedText})", text: "ome dynamic error-text, based on the value ${newValue}" } ] } }); const isValidFunction = () => false; // dummy FunctionFactory.Instance.register("isValidFunction", isValidFunction);
Please let me know if this is an option.
Hi Jane, thanks for your reply. Unfortunately that's not possible, because the validation changes every time a value changes in another component (
myLimitChoices
). But maybe this is a similar problem/bug to my other ticket: https://surveyjs.answerdesk.io/ticket/details/t15109 so maybe this will be fixed in the future?Hi Mario,
Thank you for your follow-up. I suppose this fix may resolve the issue and the error indication should appear within a custom component's input. Once the next maintenance update is available, please feel free to upgrade and check to see if the issue is resolved.
Should you have any further questions, please feel free to contact us at any time.
Thanks