Liveview won’t update inputs, which are focused anyways. So no matter what you do you cannot live replace the text in an input as user currently writes to without additional js. Given the latency of liveview I’d also strongly suggest to not even try to format input field values server side. I even had problems with js libraries being quite annoying by trying to format while supplying input (and in the mean time screwing up what I intended to write).
There are imo three options (from most to least prefered in my opinion):
-
Don’t do it
Just let users supply number is whatever format they want to and apply formatting only afterwards. If you’re worried about incorrect inputs opt for making corrections easier or show a formatted preview next to the input. -
Use JS library
There are js libraries created for formatting input with delays or while writing. If they support cldr you might eben be able to supply patterns of ex_cldr to them. -
Take on the complexity head on
With client and server doing concurrent edits to text you’re tech. dealing with distributed state. One way to handle that could be using delta-elixir, which slab released recently, and the js counterpart and actually treat the changes made to the text like distributed changes, which need later consolidation. This is overengineering at its finest for your usecase, but I wanted to include it just to show the level of complexity the core of the requested functionality entails.






















