246
Views
1
Comments
Input box that allows one decimal point and two numbers after the decimal point
Question

Hi Outsystems team,

I have used the list to display the fees to be paid. Inside that list i placed the input box to enter the values. I But the input box should allow only one decimal point and after that decimal point it should allow the two numbers. 

I used the java script to achieve this. But i am facing issue like when i am entering the numbers and then i tried to type any special characters in it the whole value gets erased. Is there any other way to achieve this??

var input = document.getElementById($parameters.TextboxId);
input.addEventListener("keyup", function(event){
this.value = this.value.replace(/[^\d.]/g, '');            // numbers and decimals only
/*this.value = this.value.replace(/(\..*)\./g, '.'); */       // decimal can't exist more than once
this.value = this.value.replace("..",'.');
this.value = this.value.replace(/(\.[\d]{2})./g, '$1');    // not more than 2 digits after decimal/*
});


Regards,

Indumathy V


2020-02-28 09-46-54
Eduardo Jauch

Hi, 

You can use a Mask component associated with your input. It has all the requires Javascript. 

Just search in the Forge by Mask. 

Cheers 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.