Security code

SecurityCodeControl

Collect verification codes, PINs and short references one character per box.

Overview

SecurityCodeControl is a Blazor one-time-code input: one box per character for verification codes and PINs, joined into one bound Value. Use it for two-step sign-in, confirming an email address or typing an employee id; OnComplete fires when the last box is filled, so you can check the code without a Submit button. Length sets the number of boxes, and Type allows digits only or letters too.

Examples

#Verification code

Type the six digits (the demo code is 492018), with Tab between boxes: OnComplete checks the code once every box is filled, and a match sets Disabled to lock the boxes.

We texted a code to Hermione Ranger's phone ending 0142. Enter it to confirm leave request LR-0107.

Awaiting code

0 of 6 digits entered

#Letters and digits

Look up an employee by id: Type set to AlphaNumeric accepts letters as well as digits, and Length sets the number of boxes.

Type an employee id without its hyphen: three letters and four digits, such as EMP0017, EMP0042 or EMP0051.

0 of 7 characters entered

Documentation

ParameterTypeDefaultDescription
Valuestring?nullThe joined characters. Two-way with @bind-Value; a cleared middle box leaves a space.
Lengthint6Number of boxes.
TypeSecurityCodeControl.SecurityCodeTypeNumericNumeric takes digits only and renders type="tel"; AlphaNumeric takes any character.
DisabledboolfalseDisables every box and grays the host. The base Enabled is not read by this control.
CssClass / Style (base)string?nullOn the host element. The base Visible is not applied.
Id / Title / Tag / Data / Parent (base)nullAccepted but not rendered. A written id binds to Id, so it does not reach the host.
(unmatched attributes)Dictionary<string,object>—Written on the host <div>, not on the boxes, such as data-*.
An unhandled error has occurred. Reload 🗙

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.