-
Notifications
You must be signed in to change notification settings - Fork 844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Text validator validates empty string #3065
Comments
Just checking this programmatically with the textfield. Doing But if I do: survey.setValue('question1', 'hey'); // Has minimum length 50000
survey.setValue('question1', ''); // Simulating empty textbox in UI It will fail validation and prevent the survey from continuing/completing. But doing survey.setValue('question1', 'hey'); // Has minimum length 50000
survey.setValue('question1', null); allows it to pass validation. |
@mwrouse We do not validate a question value if it is empty. However, entering the empty string should make the question value empty. I will take a look. Thank you, |
@andrewtelnov I assumed that is the case, but it appears something is wrong, since erasing the contents of a textbox will result in an empty string. And doing it programmatically shows that. I also assume this is exists for textfields and such. https://jsfiddle.net/mwrouse/qzfw87hL/4/ Shows that at least the checkbox questions are getting validated (on complete) when there is nothing set. Thanks for your quick help! |
@mwrouse I found an old unit case where text validator returns error on checking an empty string. Thank you, |
Thanks, I'm glad these are turning out to be rather easy, looks like that one was just a little logic error. Should I open another bug for this:
Or is that, for some reason, intended behavior? Or was it also solved with this? |
@mwrouse I am not sure about this one. I am afraid that some people is already used to have the current behavior. Thank you, |
We produce an enterprise software, on one part of it customers have the ability to create surveys. So yes, I'm sure we will have issues. There is nothing clear that makes it known that setting a validation requirement like that means that the question becomes required. It would be a breaking change if introduced, but it would obviously make it more consistent. If you need the question to be answered, you have to mark it as required. |
@mwrouse I have checked unit tests and we do not have any unit case that checks answer count validator against an empty array. It means that I could make the changes. Here is the related issue. Thank you, |
@andrewtelnov Just to confirm, but the fix you added will apply to all questions that have any kind of textfield for the input right? Comment and as well as multiple text? |
Are you requesting a feature, reporting a bug or asking a question?
Question? Bug?
What is the current behavior?
If you have a texfield with validation (minimum length) then when you start the survey, you are able to complete the survey since these values are empty.
However, if you type in the textfield, you can't undo that action after the value has been set. Erasing the contents of the textfield won't allow it to pass validation anymore.
What is the expected behavior?
I would expect that if a question is not marked as required, that it should be able to pass validation without having a value set.
Even if you set the value, but then later change the value (e.g. a textfield with minimum length validation), it should not hold up the survey unless marked as required.
How would you reproduce the current behavior (if this is a bug)?
Make a survey with a textfield that has a minimum length > 0
Run the survey, don't set any values and you will be able to complete the survey.
Run the survey again, type in the textbox field, and click out of the field. Then if you erase the contents you will fail the minimum length validation.
Provide the test code and the tested page URL (if applicable)
Tested page URL: https://jsfiddle.net/mwrouse/abo3eLdk/5/
Test code
Specify your
The text was updated successfully, but these errors were encountered: