So im building an application where the user has to input some values of type integer and i can manually verify if he inputs negative values but still the input can go to negative values.

Is there a way to easily set a minimum to 0 so the users won't input negative values?

You could take a look at the HTML properties for numeric input. In OutSystems, you can specify them as extended properties. However, I don't think you'll be able to actually prevent anyone from entering a minus sign for example.

Processing Upload...

Hi Tiago,

I attached a sample that uses JavaScript to prevent user from entering negative values. Hope it helps!

Best Regards!

Hi Tiago,

In case you are using Reactive Web application, you can use onblur event of the input box:


In case you have Traditional web, you can do the same using JavaScript.

SyntaxEditor Code Snippet

function getAbsoluteValue(number){
    var absoluteValue = Math.abs(-7.25);
}


Regards,

Saugat

Hi friend.

I usually use an OnChange action to verify the content any time that the user input a value. Following that path, you can point many input as you want to the same action and don't need to use JavaScript.

Creta the OnChange action and put an If. Set the condition like [ ValueVarTyped >= 0 ]. If the typed value goes to the false branch, replace the zero value to the variable with and assign and refresh the input field.

You also can set the Input.Valid to false and send an input error message to the user.