Form numeric field with 0 initial value issue


#1

I have noticed strange behaviour on numeric fields when the initial value is numeric zero

{
    id: "cost",
    type: "input",
    label: "Cost",
    validation: "numeric",
    value: 0
}

clicking in the field and then tabbing out causes the field to clear itself. Both below are ok although:

    value: 100

    value: "0"

#2

I encountered the same issue, although it’s not only with the initial value. If you programmatically set the value of a form field to 0, then use getValue() to get the current value, it’s empty. In my case, it showed the content of the form field to be 0, but doing a parseInt() on the value returned “NaN”. Of course, if you set it as “0”, it works fine. I haven’t dug into the code, but I suspect they’re doing a test on the input value, and not accounting for 0 as an allowed value so it’s evaluating as false.


#3

Thank you for your note.
The problem is confirmed. We’ll try to solve it in the future updates.


#4

Your problem was fixed.
Please, try to get the latest build of the dhtmlxForm to get the fixed version:
https://snippet.dhtmlx.com/eet61v19