gitana / alpaca

Alpaca provides the easiest way to generate interactive HTML5 forms for web and mobile applications. It uses JSON Schema and simple Handlebars templates to generate great looking, dynamic user interfaces on top of Twitter Bootstrap, jQuery UI, jQuery Mobile and HTML5.
http://www.alpacajs.org
Other
1.29k stars 371 forks source link

Dependencies don't work if base field is type number #718

Open ambischof opened 5 years ago

ambischof commented 5 years ago

If you have field that is of type number and another field depends on it, it will always be present. It looks like this is because number fields have a value of NaN when empty and Alpaca's Alpaca.isValEmpty function returns false for NaN.

In the Alpaca.isValEmpty code, there is even a commented out check for isNaN. There's no explanation in commits as to why this was commented out.

Seems like either the isValEmpty needs to be fixed to deal with NaN or the number field needs to not have a value of NaN when empty.

JSFiddle https://jsfiddle.net/anneb574/pgoLktqu/ See that the dependent field is always shown. If you change count field to type string, it works as expected.

JintNiu commented 2 years ago

I have the same problem. And then I uncommented it In the Alpaca.isValEmpty code. hahaha