How to prevent users from entering negative numbers?

Hi,

I want to prevent the user from entering negative numbers or characters in the input.
i know that i can but min value to 0 and this will show a validation error to the user but i want to delete the negative sign when the user enters it.

and if the input is integer the user can write characters in the input and i don’t want the input to accept it too (not just validation, i want to remove these characters)

is it possible to do so?

Hello, what is your bubble knowledge level? Do you know how states work for example?

1 Like

yes, I know how states work and I have been working with bubble for months

Great. So you need to check the input every time it’s changed.
image

If the value < 0, multiply it by -1 and replace the value in the input field.

By the way, users cannot enter any characters except numbers if you select ‘integer’ as the content format. Could you show me the problem you encountered, please?

1 Like

Thanks, I will try your solution

and the other problem is the user can enter some symbols if the input format is Integer like this

image

I see. Then you can select Text (numbers only)
image

1 Like

that is a good idea but I need the number to be between 0 and 1000 so I was using the “set a range (min and max)” but this isn’t available for the Text (numbers only)

You can check the value and if it’s greater than 1000, you can replace the value with 1000 or make it empty

1 Like

I think that this will work
thanks a lot