Question T13772
Visible to All Users

Only apply valid expressions when submitting a new answer

created 2 years ago (modified 2 years ago)

Hi there,

In case the input type of a text question is changed, some expressions that are not appliable on input type text are still applied on form submission and then a wrong validation error is shown.

Steps to reproduce

  1. Create a question of type text and input type date
  2. Set the max value expression of this question to today()
  3. Change the input type from date to text
  4. Try to ansewr the survey filling "test" on this question
  5. An error as on the image attached will be shown

error submitting.png

After the whole process the json should look like this

JSON
{ "pages": [ { "name": "nps-panel", "elements": [ { "type": "panel", "name": "nps-panel", "elements": [ { "type": "text", "name": "question1", "isRequired": true, "maxValueExpression": "today()" } ] } ] } ], "showPrevButton": false, "showQuestionNumbers": "off", "completeText": { "fr": "Envoyer" }, "questionsOnPageMode": "questionPerPage", "widthMode": "static", "width": "1000px" }

I think that expressions that are not applicable to the current input type should not be applicable when submitting the answer.

Best regards,
Luan

Answers approved by surveyjs Support

created 2 years ago

Hello Luan,
Thank you for the comprehensive explanation.

The inputType and the maxValueExpression validation work independently. When you select a specific input type, it ensures that users provide a value in the required format. On the other hand, when you apply a validation rule, you check whether the supplied value matches the specified rule. In fact, users can specify a date value even if the input type is set to text, not just when it's set to date.

If you update a question and the validation rule is no longer relevant, you can easily remove it.

I hope this clarifies the situation. Please let me know if you have any questions or need further assistance.