Skip to content

Commit

Permalink
Merge pull request #19 from navedqb/fix--input-otp-integer-only-space…
Browse files Browse the repository at this point in the history
…-issue

fix: InputOtp IntegerOnly mode accepts "space"
  • Loading branch information
navedqb authored Sep 9, 2024
2 parents 202b78e + b32cf8f commit de4e1e4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion components/lib/inputotp/InputOtp.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export const InputOtp = React.memo(

default: {
//Prevent non-numeric characters from being entered if integerOnly is true or if the length of the input is greater than the specified length
if ((props?.integerOnly && !(Number(event.key) >= 0 && Number(event.key) <= 9)) || (tokens.join('').length >= props.length && event.code !== 'Delete')) {
if ((props?.integerOnly && !(event.code !== 'Space' && Number(event.key) >= 0 && Number(event.key) <= 9)) || (tokens.join('').length >= props.length && event.code !== 'Delete')) {
event.preventDefault();
}

Expand Down

0 comments on commit de4e1e4

Please sign in to comment.