PricingBlog

Formatting numbers/text inside of a user input

  • frankenwompus-1286685444192600165

    Fisher

    1 year ago

    I'm trying to get a users input to format as a currency as it's shown on the front end. I have the Currency Formatter component downloaded and have used it successfully in other places, but I'm not finding how to get this to work here. Any help would be great!

    I suppose I could change the element from 'Input' (right?) but if I can get this to work it'd be much less hassle.

    Thanks!
    1286685444284878951-image.png
  • needtheanswers-1286779648662835201

    needtheanswers

    1 year ago

    I‘ve also tried to make this work but ended up using formatNumber in the Toddle formula. Not quite what I wanted but you can also use this for currencies
    👍1
  • frankenwompus-1286780852142866462

    Fisher

    1 year ago

    OK, well good to know there's a workaround. Did you use that input elsewhere in your page? The reason I ask is because mine goes to an API call and I want the numbers but not the formatting.... but I want the user to see the nice formatting ha!
  • needtheanswers-1286781711195312241

    needtheanswers

    1 year ago

    I use this input a few times in my project. It also goes to my database. I think to format the input while the user is typing we would need a custom js action (currently trying to figure this out🥲).
  • needtheanswers-1286782072752574547

    needtheanswers

    1 year ago

    using formatNumber I don‘t have any issues when sending the value to my db. I multiply the value x100 because I don‘t use decimals in my db tho.
  • needtheanswers-1286783369304342592

    needtheanswers

    1 year ago

    Another idea would be to let the user typec in the value, format it using formatNumber, get the value, let the user type in, format it, get the value,.. and so on ( something like a constant back and forth between the input and the value)
  • frankenwompus-1286784805769580615

    Fisher

    1 year ago

    Do you have a screenshot of your formula? I can't seem to get it right. Also, it goes here? (Note for posterity: the attribute here should be 'value' not 'Type')
    1286784805735891025-image.png
  • needtheanswers-1286786197468876873

    needtheanswers

    1 year ago

    I actually used a variable. On input/change of the input field I would set the value of the variable. I have two versions here:
    1286786197095583819-image.png
    1286786197430997064-image.png
    🙌1
  • Depending on your "locale" it would either use a dot or a comma as a decimal separator
  • frankenwompus-1286786741075841166

    Fisher

    1 year ago

    Oh, I need a whole object! I was trying to just paste JSON into the JSON formula thing. You're a hero man, thank you! You should be "givingtheanswers"
    👍1
  • needtheanswers-1286788012566642760

    needtheanswers

    1 year ago

    You are welcome and thanks a lot for the compliment 😊