Skip to content

Commit

Permalink
copy and paste added
Browse files Browse the repository at this point in the history
  • Loading branch information
0101oak committed Sep 9, 2024
1 parent 925e0db commit ffdde7a
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/features/utilitty/removePossibilityToEnterSigns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ export const restrictNumericInput = (e: React.KeyboardEvent<HTMLInputElement>) =
'ArrowDown',
'ArrowLeft',
'ArrowRight',
'Control',
'v',
'c',
];

if (
key === 'e' ||
key === 'E' ||
(isNaN(Number(key)) && key !== '.' && !allowedControlKeys.includes(key))
(key === 'e' || key === 'E' || (isNaN(Number(key)) && key !== '.' && !allowedControlKeys.includes(key)))
&& !(e.ctrlKey && (key === 'v' || key === 'c'))
) {
e.preventDefault();
}
Expand All @@ -27,3 +29,11 @@ export const restrictNumericInput = (e: React.KeyboardEvent<HTMLInputElement>) =

selectedDot = key === '.';
};

export const handlePaste = (e: React.ClipboardEvent<HTMLInputElement>) => {
const pasteData = e.clipboardData.getData('text');

if (isNaN(Number(pasteData)) || (pasteData.split('.').length - 1 > 1)) {
e.preventDefault();
}
};

0 comments on commit ffdde7a

Please sign in to comment.