Custom Number Formats

I need to allow users to enter a specific number format whereby the first and only decimal can only go to 5 before the integer moves up a number. For example:
1.4, 1.5, 2.0, 2.1, 2.2…2.5, 3.0, 3.5…etc etc.
Is it possible to limit the decimal number but not the integer?

Many thanks!

Hi there, based on what you’ve said, I believe you’re looking to limit the types of numbers your users submit, but you don’t need to format the number once it’s been submitted, correct?

You could have conditions on the ‘submit’ button preventing it from submitting if those conditions aren’t met. I’d suggest looking at a combination of :rounded to, :floor, and :ceilingas defined here: Operators and comparisons - Bubble Docs

I would think some combo like this:

When “Input’s Value” - “Input’s Value”:rounded to: 0 is > 0.5
This element is not clickable (and give it some formatting like greyed out, and a message that says 'this number is not the correct format)

What this is doing is taking the input, let’s say they enter 1.75. The first condition is taking the input value (1.75), minus the input value rounded to no decimals (so minus 1), and saying if the resulting number (which is now 0.75) is greater than 0.5 (which in this example, it is), the user can’t submit, and will see that message.

And then to limit numbers with more than 1 decimal figure, you could add another condition with the same set of formatting changes (i.e. this element isn’t clickable, greyed out, message, etc) but with the following: When ((Input’s Value) - (Input’s Value:Rounded to 0)):formatted as (note: you can leave ‘decimal place’ empty as it won’t limit how many decimals it is counting):number of characters > 1

So with our same input example (1.75), it’s taking that input, subtracting from it that input (1.75 rounded down to no decimals, so rounded down to 1) - so we’re left with 1.75, minus 1, which is 0.75:formatted as (which then turns this into text):number of characters (which counts the characters of the text), and sees if the resulting number is greater than 1. 1 being the only number decimals! So in this case. (1.75 - 1)=0.75, counted as ‘2’ characters, so it will also fail.

I didn’t run these specific conditions myself so you may need some trial and error - but that’s the gist of how I’d approach it!

1 Like

Thank you so much - that’s really helpful! Appreciated.

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.