posted on July 5, 2016
•
Show version history
I've got the following code:
$('.comma input').attr("pattern", '^(\\d+|\\d{1,3}(,\\d{3})*)(\\.\\d{2})?$'); $('.comma input').on("change", function () { $(this).val($(this).val().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")); });
This script triggers and removes commas temporarily so that a field rule that shows/hides a field occurs if the value is over 5k or under 5k.
The issue is that this script doesn't always trigger.
If the user enters in over 5k or under 5k with no comma values, it will trigger appropriately.
However if they type in the commas, it doesn't trigger. Is there any better way to do this across the board?
0
0