Blazor OTP Input
The
OTPInput component lets users enter a one-time password (OTP) in separate fields, one character each, for sign-in and verification flows. The examples below cover events as the code is typed and completed, and a custom code length.How it works #
The OTPInput component provides a user-friendly interface for entering one-time passwords (OTP), commonly used for authentication and verification flows.
How to use:
This demo illustrates the basic usage of the OTPInput component, including event handling for OTP entry and completion.
How to use:
- Add the
OTPInputcomponent to your page. - Handle the
OnOTPChangedevent to capture the OTP value as the user types. - Handle the
OnOTPCompletedevent to respond when the user has entered the complete OTP. - Bind the entered OTP to a variable for display or further processing as needed.
Length #
The OTPInput component allows you to specify the required OTP length, adapting the number of input fields accordingly.
How to use:
This demo demonstrates how to configure the OTPInput component for a custom OTP length and handle user input accordingly.
How to use:
- Set the
Lengthparameter to define how many digits or characters the OTP should have (e.g.,Length="5"). - Handle the
OnOTPChangedandOnOTPCompletedevents as shown in the demo to process the OTP input. - Display or use the entered OTP value as needed in your application.