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

visibleIf compares numbers from text-type questions like strings #140

Closed
klvbdmh opened this issue Nov 29, 2016 · 6 comments
Closed

visibleIf compares numbers from text-type questions like strings #140

klvbdmh opened this issue Nov 29, 2016 · 6 comments
Labels

Comments

@klvbdmh
Copy link
Contributor

klvbdmh commented Nov 29, 2016

Steps to reproduce the issue:

  1. Paste the following code in the JSON Editor:
{
 pages: [
  {
   name: "page1",
   questions: [
    {
     type: "text",
     name: "Number",
     title: "Enter a number",
     validators: [
      {
       type: "numeric"
      }
     ]
    },
    {
     type: "html",
     html: "<p>Greater than 1200</p>",
     name: "Greater",
     visible: false,
     visibleIf: "{Number} > 1200"
    },
    {
     type: "html",
     html: "<p>Less than 1200</p>",
     name: "Less",
     visible: false,
     visibleIf: "{Number} < 1200"
    }
   ]
  }
 ]
}
  1. In the Test Survey tab enter the following values: 2, 100, 11111, gggg. After entering each value press Enter.

Expected behavior

  • When entering 2, the text underneath should say Less than 1200.
  • When entering 100, the text underneath should say Less than 1200.
  • When entering 11111, the text underneath should say Greater than 1200.
  • When entering gggg, the text underneath shouldn't say anything, as we already include validator for numerical values.

Observed behavior

  • When entering 2, the text underneath says Greater than 1200.
  • When entering 100, the text underneath says Less than 1200.
  • When entering 11111, the text underneath says Less than 1200.
  • When entering gggg, the text underneath says Greater than 1200.

Notes

Text is the only question type that allows entering custom numerical values, for example salary or car mileage. It looks like the values are compared like strings instead of numerical values. The current behavior is a major problem when using numerical value to customize survey logic.

@andrewtelnov
Copy link
Member

@klvbdmh I may add inputType property to the QuestionText class.
The default is "text". There will be "numeric", "date", "datetime" and other options.
Will it work for you?

@andrewtelnov
Copy link
Member

@klvbdmh However, I can see, there is an issue with numeric validator as well. I will look at it. Thank you.

@klvbdmh
Copy link
Contributor Author

klvbdmh commented Nov 30, 2016

@andrewtelnov

I may add inputType property to the QuestionText class.

That would be fantastic.

@andrewtelnov
Copy link
Member

@klvbdmh It is implemented: #141

@andrewtelnov
Copy link
Member

@klvbdmh validation works as expected. It is executed on clicking page next and complete.
I have tried your json with inputType: "number" and it works as expected now. Plus Chrome shows nice spin buttons.
I think, it is a better solution.

@klvbdmh
Copy link
Contributor Author

klvbdmh commented Dec 2, 2016

Yes, changing inputType to "number" works great now. Thank you.

@klvbdmh klvbdmh closed this as completed Dec 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants