nobt-io / frontend

Frontend of nobt.io.
https://nobt.io
GNU General Public License v3.0
10 stars 4 forks source link

Parse comma decimal numbers to dot decimal numbers #62

Closed wendevlin closed 7 years ago

wendevlin commented 7 years ago

It is not possible to add a bill with a comma separated amount like (2,30 €). Tested with Firefox Mobile. You should also allow such inputs and parse it on saving. Moreover is the error message not very useful. screenshot_20170911-102148

thomaseizinger commented 7 years ago

Hi @masterwendu! I agree that the error message is not very helpful. A decimal amount should work though. I will look into it!

thomaseizinger commented 7 years ago

The problem is that Firefox triggers the onChange handler only on blur whereas Chrome triggers it on every keystroke. This only happens for input fields of type number. Therefore our input-validator, which is bound to the onChange event, is not triggered in Firefox. Unfortunately, there is no consistent support across mobile browsers for other events like onKeyPress, onKeyDown or onKeyUp. Those events would allow a different implementation in which we cancel the original event and only pass through the pressed key if it is valid (i.e. numbers or dots). I haven't found a solution yet, that works across all browsers and delivers a good user experience.

wendevlin commented 7 years ago

Oh ok, Then I would trigger input-validator onBlur and on save of the bill. Or is this a issue?

thomaseizinger commented 7 years ago

The whole idea of the validator was to provide assistance to the user as they type so that they can never enter an invalid amount. So triggering the validator onBlur doesn't really help.