diff --git a/src/number_format_base.tsx b/src/number_format_base.tsx index 64f1287..c80d357 100644 --- a/src/number_format_base.tsx +++ b/src/number_format_base.tsx @@ -154,9 +154,9 @@ export default function NumberFormatBase( inputValue?: string; input?: HTMLInputElement | null; event?: - | React.ChangeEvent - | React.FocusEvent - | React.KeyboardEvent; + | React.ChangeEvent + | React.FocusEvent + | React.KeyboardEvent; source: SourceType; }) => { const { formattedValue: newFormattedValue = '', input, source, event, numAsString } = params; @@ -432,6 +432,7 @@ export default function NumberFormatBase( onMouseUp: _onMouseUp, onFocus: _onFocus, onBlur: _onBlur, + pattern: /[^0-9,.]/, }); if (displayType === 'text') { diff --git a/src/numeric_format.tsx b/src/numeric_format.tsx index fd1281a..38a3b40 100644 --- a/src/numeric_format.tsx +++ b/src/numeric_format.tsx @@ -561,6 +561,7 @@ export function useNumericFormat( getCaretBoundary: (formattedValue: string) => getCaretBoundary(formattedValue, props), onKeyDown: _onKeyDown, onBlur: _onBlur, + pattern: /[^0-9,.]/, }; }