diff --git a/src/number_format.js b/src/number_format.js index 14b8cfe0..486e15ad 100644 --- a/src/number_format.js +++ b/src/number_format.js @@ -359,6 +359,18 @@ class NumberFormat extends React.Component { } /** caret specific methods ends **/ + convertFullwidthToHalfwidth = (val: string) => { + let ascii = ''; + for(let i=0, l=val.length; i= 0xFF00 && c <= 0xFFEF) { + c = 0xFF & (c + 0x20); + } + ascii += String.fromCharCode(c); + } + return ascii + } /** methods to remove formattting **/ removePrefixAndSuffix(val: string) { @@ -603,6 +615,8 @@ class NumberFormat extends React.Component { const {selectionStart, selectionEnd} = this.selectionBeforeInput; const {start, end} = findChangedIndex(lastValue, value); + value = this.convertFullwidthToHalfwidth(value) + /** Check if only . is added in the numeric format and replace it with decimal separator */ if (!format && decimalSeparator !== '.' && start === end && value[selectionStart] === '.') { return value.substr(0, selectionStart) + decimalSeparator + value.substr(selectionStart + 1, value.length);