diff --git a/src/number_format.js b/src/number_format.js index 20af6e38..1e78bc52 100644 --- a/src/number_format.js +++ b/src/number_format.js @@ -426,7 +426,7 @@ class NumberFormat extends React.Component { } } - return (numStr.match(/\d/g) || []).join(''); + return (numStr.match(this.getNumberRegex(true)) || []).join(''); } removeFormatting(val: string) { @@ -442,7 +442,7 @@ class NumberFormat extends React.Component { //condition need to be handled if format method is provide, val = removeFormatting(val); } else { - val = (val.match(/\d/g) || []).join(''); + val = (val.match(this.getNumberRegex(true)) || []).join(''); } return val; } diff --git a/test/library/input.spec.js b/test/library/input.spec.js index 186bda9f..21491ebc 100644 --- a/test/library/input.spec.js +++ b/test/library/input.spec.js @@ -30,6 +30,18 @@ describe('NumberFormat as input', () => { expect(wrapper.state().value).toEqual('1234567890'); }); + it('should accept and format custom numerals together with format input field', () => { + const wrapper = mount( + , + ); + simulateKeyInput(wrapper.find('input'), '۱۲۳۴۵۶۷۸۹۰', 0); + + expect(wrapper.state().value).toEqual('1234567890'); + }); + it('should render input as type text by default', () => { const wrapper = mount(); expect(wrapper.find('input').instance().getAttribute('type')).toEqual('text');