guilhermerodz / input-otp

One time passcode Input. Accessible & unstyled.
https://input-otp.rodz.dev
MIT License
2.35k stars 47 forks source link

Do something after all required fields where inserted #50

Closed ImamJanjua closed 2 months ago

ImamJanjua commented 2 months ago

Hi, how can i perform some action after the user has filled all the required input fields. But like without a button to submit?

NicolasCassunde commented 2 months ago

You can use OnComplete to do it

<InputOTP onComplete={(e: string) => onComplete(e)} maxLength={6}> <InputOTPGroup> <InputOTPSlot index={0} /> <InputOTPSlot index={1} /> <InputOTPSlot index={2} /> </InputOTPGroup> <InputOTPSeparator /> <InputOTPGroup> <InputOTPSlot index={3} /> <InputOTPSlot index={4} /> <InputOTPSlot index={5} /> </InputOTPGroup> </InputOTP>

guilhermerodz commented 2 months ago

Check out @NicolasCassunde response