Class VinKeyboardValidator
- Namespace
- NuvTools.AspNetCore.Blazor.MudBlazor.Validators
- Assembly
- NuvTools.AspNetCore.Blazor.MudBlazor.dll
Keyboard validator for Vehicle Identification Number (VIN) input.
public sealed class VinKeyboardValidator
- Inheritance
-
VinKeyboardValidator
- Inherited Members
Remarks
VINs do not use the letters I, O, and Q to avoid confusion with the numbers 1, 0, and 9 respectively. This validator blocks these invalid keys during input.
Use with MudTextField's OnKeyDown event and PreventDefault property:
@code {
private readonly VinKeyboardValidator _vinValidator = new();
}
<MudTextField @bind-Value="Vin"
OnKeyDown="_vinValidator.OnKeyDown"
KeyDownPreventDefault="_vinValidator.IsKeyBlocked" />
Properties
IsKeyBlocked
Gets a value indicating whether the last key pressed should be blocked.
public bool IsKeyBlocked { get; }
Property Value
Methods
IsValidVinKey(string)
Checks if the specified key is a valid VIN character.
public static bool IsValidVinKey(string key)
Parameters
keystringThe key to validate.
Returns
- bool
trueif the key is valid for VIN input; otherwise,false.
OnKeyDown(KeyboardEventArgs)
Handles the key down event and determines if the key should be blocked.
public void OnKeyDown(KeyboardEventArgs e)
Parameters
eKeyboardEventArgsThe keyboard event arguments.