brutusin / json-forms

JSON Schema to HTML form generator, supporting dynamic subschemas (on the fly resolution). Extensible and customizable library with zero dependencies. Bootstrap add-ons provided
http://brutusin.org/json-forms
Apache License 2.0
610 stars 168 forks source link

Integer/number field validation message #18

Closed ghost closed 8 years ago

ghost commented 8 years ago

You get the following validation message if you write a non number data in a number type (integer, number) input field: "This field is required". It would be better a message about the conversation error.

idelvall commented 8 years ago

I cannot reproduce this case. Can you attach the schema? What browser are you using?

ghost commented 8 years ago

I used http://brutusin.org/json-forms for tests.

At "Objects, arrays, enums, default, required, minItems" test write "aaa" into the Page number input field and fill two Query terms.

And an other interesting behaviour: At "Numeric validation" test write something non-numerical into the input boxes and the push validate button (Validation succeeded).

With Firefox 45.0 you can enter non-numerical value into input box. I checked Chrome and it is smarter (you can't write non-numerical characters into the input field).

After a little searching I found this: http://stackoverflow.com/questions/19966417/prevent-typing-non-numeric-in-input-type-number . Now I understand the "This field is required" message. You can close this issue if you want.

idelvall commented 8 years ago

Yes, this is an issue from Firefox. I remember facing it in the past. I decided not to include any key filtering because it seems to be difficult to achieve a great cross-browser solution. Anyway if you want to include a key event filter like the commented in SO, you can do it using a decorator for input of type "number". Thanks!

ghost commented 8 years ago

You're right, cross-browser compatibility was never easy. :( I will try this decorator. Thanks!