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
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
Hi @GOKULPRASANTH M
Refer this link it will help on you requirements
https://www.outsystems.com/forums/discussion/65176/how-to-limit-the-input-with-number-type/
Thanks
Hi King Fizel
Thanks For the Response But my requirement is not solved..
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.
King Fizel
Hi @GOKULPRASANTH M ,
Please find below forum links for reference.
https://www.outsystems.com/forums/discussion/47181/how-to-allow-2-decimal-places-in-input-widget/
https://www.outsystems.com/forums/discussion/63784/restrict-user-from-entering-not-more-than-two-decimal-points/
There is also a forge component available for this:
https://www.outsystems.com/forge/component-overview/647/custom-input-masks-o11
Anjali
Hi Anjali
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
Hi Ajay Dadhich
We will use Regex but while entering a value how we will restrict.
Thanks,
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.