147
Views
9
Comments
Solved
Restrict upto two decimal in input
Application Type
Reactive
Service Studio Version
11.54.60 (Build 63294)
Platform Version
11.28.0 (Build 43201)

Restrict up to two decimal in input widget while user enter a value and the datatype of input variable is Decimal(37,2) . Thanks in Advance!!!



Regards,

Gokulprasanth M

2022-07-05 06-54-15
GOKULPRASANTH MUNUSAMY
Solution

Thanks for all your response .

I used this JS It is working properly for me

document.getElementById($parameters.Inputid).addEventListener('input', function (e) {    

let value = e.target.value;    

if (value === '') return;      

 const regex = /^\d*\.?\d{0,2}$/;  

  if (!regex.test(value)) {       

 e.target.value = e.target.getAttribute('data-last-valid') || '';  

  } else {             

  e.target.setAttribute('data-last-valid', value);    }});


Regards

Gokulprasanth M

UserImage.jpg
King Fizel
2022-07-05 06-54-15
GOKULPRASANTH MUNUSAMY

Hi King Fizel 

Thanks For the Response But my requirement is not solved..


Regards,

Gokulprasanth M

UserImage.jpg
King Fizel

Hi @GOKULPRASANTH M 

Can you share the screenshot or oml. For you requirements

Have you look the oml attached below on that link?

https://www.outsystems.com/forums/discussion/65176/how-to-limit-the-input-with-number-type/.

I tried my side its working as expected, to set max 2 value in decimal its look like (2. or 22) and you have to set max length 3 to look like this (2.1 & 0.5). "Dot" takes one extra length. Try to set max 3. and try. 


Thanks

King Fizel

2022-07-05 06-54-15
GOKULPRASANTH MUNUSAMY

Hi Anjali

Thanks For the Response But my requirement is not solved..


Regards,

Gokulprasanth M

2020-06-04 07-36-47
Ajay Dadhich

Hi @GOKULPRASANTH M 

Simply use the below regex in your flow and validate your input.

^[0-9]*\.[0-9]{2}$

Feel free to write me back if you have any concerns about this.

Thanks

2022-07-05 06-54-15
GOKULPRASANTH MUNUSAMY

Hi Ajay Dadhich

We will use Regex but while entering a value how we will restrict.


Thanks,

Gokulprasanth M 

2020-06-04 07-36-47
Ajay Dadhich


Hi @GOKULPRASANTH M 

In the flow, you will check the regex response. If it returns true, proceed with the rest of the flow. If it returns false, display an error message and end the flow immediately.

If you still have concerns or doubts, please share the OML file. I will review it and assist you further.

Thanks

2022-07-05 06-54-15
GOKULPRASANTH MUNUSAMY
Solution

Thanks for all your response .

I used this JS It is working properly for me

document.getElementById($parameters.Inputid).addEventListener('input', function (e) {    

let value = e.target.value;    

if (value === '') return;      

 const regex = /^\d*\.?\d{0,2}$/;  

  if (!regex.test(value)) {       

 e.target.value = e.target.getAttribute('data-last-valid') || '';  

  } else {             

  e.target.setAttribute('data-last-valid', value);    }});


Regards

Gokulprasanth M

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