Table of Contents

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

bool

Methods

IsValidVinKey(string)

Checks if the specified key is a valid VIN character.

public static bool IsValidVinKey(string key)

Parameters

key string

The key to validate.

Returns

bool

true if 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

e KeyboardEventArgs

The keyboard event arguments.