Setting input limit

Is there a way i can set an input limit to a certain value with js? The other way of setting limit in the input settings is not applicable because i would like each user to have his own limit.
I have tried using a cache collection in another database which will compare the input element with a the cache vale but seems it is not working. Here is the code and I would appreciate any help.


export function button300_click(event) { 
 let cache= $w('#dataset25').getCurrentItem().cache;
 let sumHrs= $w('#dataset24').getCurrentItem().pnumber;
 let withdraw=$w('#input9').value
 if(cache<withdraw){
        $w('#button300').hide()
        $w('#text21').text="You have insufficient funds to withdraw "+$w('#input9').value;
    }
 else{
         $w("#dataset21").onReady(() => {
            $w('#dataset21').setFieldValue('phoneNumber', sumHrs)
            $w('#dataset21').setFieldValue('status', "Pending")
            $w('#dataset21').save()
        })
    }}

Hello pay.surv,
take a look at this example…
https://russian-dima.wixsite.com/meinewebsite/blank-17
Perhaps it is, what you are looking for.

Hello Russian dima, i have openen your code and have realized you have created for character limit. My issue is slightly different since am trying to set a limit for numerical input.

Give some examples for numerical limits?

You can put into a inputfield some values. These can be NUMBERs, STRINGS and a few more, but you can manipulate the value.lenghth of all of them, right?

So if i would say, the numerical input-limit is [999] <Number, so you say, that if the length of the value >= 3 —> do something, if not, do somthing else.

Isn’t it a limitation? You would limit your input to 3-characters. With this 3-characters your max NUMBER is —> 999, et voila, you have your limitation.

Of course it’s not a complete limitation, but you can expand the code and modify it much more.

But perhaps i did not understand what you want :grin:

Your example is used to set the number of characters in an input field. But my issue is how to set a limit value. For instance if i want input to be 4, all values from 1 to 4 will be accepted e.g
000001,
0.00099 ,
2.938,
3.9999999
For your case

Now i know what you mean.

Then try to work with something like —> parseFloat, or round-methods.

Do not know if this example fits, but it do what you are searching for, on my opinion.

https://russian-dima.wixsite.com/meinewebsite/blank

Use the lower input and type in your example-numbers with “.” and then with “,” as separator (and do not forget to activate the “parseFloat”-function :grin:

If you just work with —> " , " this will work.
You should think about, how to EXCLUDE —> the point " . "

So now you should have enough tools, to achieve your aim.
Here you have some more input…
https://www.w3schools.com/js/js_number_methods.asp

@russian.dima You seem to be suggesting a regex to regulate the input value which will allow for whole numbers and decimals. That is no what am looking for for actually. Please go back to my original post and follow it through.