Skip to content

Commit bcad913

Browse files
authored
fix pasting string started with number
if you paste a value like 123er the number check passes
1 parent 4ab5905 commit bcad913

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ const ReactInputVerificationCode = ({
144144
const pastedString = e.clipboardData?.getData('text');
145145
if (!pastedString) return;
146146

147-
const isNumber = !Number.isNaN(+pastedString);
147+
const isNumber = new RegExp(/^\d+$/).test(pastedString);
148148
if (isNumber) setValue(pastedString.split('').slice(0, length));
149149
};
150150

0 commit comments

Comments
 (0)