How to validate a 5 characters input of textbox that the first 3 characters to letters only and the last 2 characters to numbers c# [closed]

You can use RegEx [A-Za-z]{3} – Matches 3 alpha [0-9]{2} – Matches 2 numbers

Test your inputs with given regex online https://regex101.com/r/fF4zG9/5

                Regex temp = new Regex("^[A-Za-z]{3}[0-9]{2}$");
                string yourVal = "asd12";
                if(temp.IsMatch(yourVal))
                {
                    //Matches
                }
                else
                {
                    //Fails
                }

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top