diff --git a/number/number.view.tree b/number/number.view.tree index 219f33fb79..a2ac3979c6 100644 --- a/number/number.view.tree +++ b/number/number.view.tree @@ -7,7 +7,7 @@ $mol_number $mol_view enabled true sub / <= String $mol_format - allow \0123456789.- + allow \0123456789,.- mask* <= mask* \ - \ we don't want native number controls in mobile devices - \ https://stackoverflow.com/questions/3790935/can-i-hide-the-html5-number-input-s-spin-box diff --git a/number/number.view.ts b/number/number.view.ts index dd3c9501aa..62085a60c7 100644 --- a/number/number.view.ts +++ b/number/number.view.ts @@ -51,7 +51,7 @@ namespace $.$$ { if (next === undefined) return current const minus = next.includes('-') - next = next.replace(/[^\d\.]/g, '') + next = next.replace(/,/g, '.').replace(/[^\d\.]/g, '') if ( minus ) next = '-' + next const dot_pos = next.indexOf('.') @@ -67,15 +67,17 @@ namespace $.$$ { } @ $mol_mem - formatter() { - return new Intl.NumberFormat() + static formatter() { + return new Intl.NumberFormat('en-EN') } + formatter() { return this.$.$mol_number.formatter() } + override mask(val: string) { if (! val) return '' - const current = Number(val.replace(/[^\d\.\-]/g, '')) + const current = Number(val.replace(/,/g, '.').replace(/[^\d\.\-]/g, '')) if (Number.isNaN(current)) return '' - return this.formatter().format(current).replace(/[^\s]/g, '_') + return this.formatter().format(current).replace(',', ' ').replace(/[^\s]/g, '_') } @ $mol_mem