Skip to content
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

Textfield component triggers validation when input has the value of 0 #5554

Open
molequetu opened this issue Apr 2, 2024 · 3 comments
Open

Comments

@molequetu
Copy link

Describe the bug
Hello, I use a textfield component from which I use validation for required and a regex pattern in order to allow only numbers
Here is the configuration of the textfield
{ "label": "Last Year's Income", "tableView": true, "type": "textfield", "validate": { "required": true, "pattern": "[0-9]*", "customMessage": "Please provide only numbers" }, "key": "parent2PreviousYearIncome", "input": true },
In the first time I am able to save using as input the value 0. After re-render of the form with the data, with no changes made in the textfield, when i press save / submit, validation gets trigger for unknown reason. I tried remove the regex pattern for numbers, but still the validation gets triggered as the field is required although it has the value 0. If I re-enter value 0 in the textfield it gets saved correctly.

The validation gets triggered only for the value 0, using other values e.g 1 does not trigger it.

Version/Branch
^4.17.1

To Reproduce
Steps to reproduce the behavior:

  1. Create a textfield with validation required
  2. Put the value 0 and save - success
  3. Reload the form, click save without changes and the validation gets triggered althoug it has value

Expected behavior
Textfield should treat 0 as a value and not trigger validation.

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

Additional context
Add any other context about the problem here.

@lane-formio
Copy link
Contributor

I suppose I'm curious why you aren't just using a number component here. If someone would like to look into this we are always willing to review contributions, but the use-case here is unclear to me and I don't see us resourcing it.

@molequetu
Copy link
Author

molequetu commented Apr 3, 2024

@lane-formio the reason i am not using number is this issue #4032
My first option ofc was to use a Number component but as referenced it has a problem in posting null values.

@lane-formio what is exaclty unclear to you? If i can help tell me.

@VikkiAlenn
Copy link

@molequetu Could you try to reproduce the same scenario in formioJS 4.19.0, for example?
Or, please, check the steps in our video and let us know if we are reproducing that correctly.

chrome_eXXktzacNu.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants