New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support alphanumeric #35
Comments
hi @deadcoder0904 I believe using TypeScript to narrow down inputMode to be either https://github.com/guilhermerodz/input-otp/blob/master/packages/input-otp/src/types.ts#L21 In fact, the feature you want already works out-of-the-box, it's just TypeScript complaining. You might be able to go with I'll remove inputMode type restriction and push into the newest 1.2.0 which will be released today. thanks for sharing. |
how do i make it work? i tried <OTPInput
value={value}
onChange={setValue}
maxLength={6}
// @ts-ignore
inputMode={"text" && "numeric"}
/> |
I think you might be referring to native HTML input's pattern attribute?Since input-otp works with native inputs, you can provide a prop <OTPInput
+ // overrides the default numeric pattern
+ // you can use any pattern you want
+ pattern='^[a-zA-Z0-9]+$'
/> Alternatively, the library offers regexps so you don't have to remember them: import {
OTPInput,
+ REGEXP_ONLY_DIGITS_AND_CHARS
} from 'input-otp'
<OTPInput
+ pattern={REGEXP_ONLY_DIGITS_AND_CHARS}
/> There's no official HTML inputmode value such as From my side, I'll
|
closing this for now, let me know if you run into any issues forward |
does i mean is it the same as the pattern looks like typescript says it is the same. thanks for the solution :) |
i'm curious do i need it works without it but i'm not sure if it's the best way? |
Just a newbie Typescript developer here. A quick glance at the docs, and I thought that this would work to support text, but it did not:
This is what got it working for me:
|
Is your feature request related to a problem? Please describe.
I want both letters & numbers. Its pretty common in various services that I use for OTP.
Heck, most authenticator apps like Twitter use alphanumeric. Ik this bcz its logging me out for the last 30 days everyday so I have to type it out lol.
Describe the solution you'd like
Implementation: https://github.com/pilcrowOnPaper/oslo/blob/c1f60eca2137cda93bb7aefed35781d85d12c7b6/src/crypto/random.ts#L52-L67
The text was updated successfully, but these errors were encountered: