Search code examples
c#validationtextboxmaskedtextbox

How do I validate an input requiring two hex characters?


I want to validate a string value from textbox.

Validation requirements are:

  1. Exactly 2 characters
  2. Hex characters only

How can I do this?


Solution

  • Use a Regex validator control with the expression: ^[0-9A-F]{2}$