diff --git a/ynr/apps/utils/widgets.py b/ynr/apps/utils/widgets.py index 702a55f28..85fccbd87 100644 --- a/ynr/apps/utils/widgets.py +++ b/ynr/apps/utils/widgets.py @@ -58,7 +58,13 @@ def build_attrs(self, base_attrs, extra_attrs=None): { "pattern": r"[0-9\s\.]*", "oninvalid": "this.setCustomValidity('Enter a percentage or a whole number')", - "onchange": "this.value = Math.round(this.value.replace(/\D/g, '')).toString()", + "onchange": """ + let value = this.value.replace(",", "."); + value = value.replace("%", ""); + value = value.trim(); + value = Math.round(parseFloat(value)).toString(); + this.value = value; + """, } ) return attrs