Hello there, I am currently developing a directive in AngularJS that specifically allows only positive numbers and decimal values. Any characters other than numbers (such as +, -, abc...) will be removed from the input.
Initially, I attempted to achieve this using the following code:
var transformedInput = text.replace(/[^0-9]/g, '');
Although this worked well, it did not support decimal numbers. Hence, I modified my approach to:
transformedInput = text.replace(/[^0-9]+([,.][0-9]+)?$/g, '');
I am encountering some issues with my code. Could someone please review it and provide assistance?