how to add alphanumeric validation without adding space and special charecters
Validation
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
how to add alphanumeric validation without adding space and special charecters
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Uday DodiyaRank #239 · 10.3K reputationPosted Oct 7, 2022, 1:57 AM EDT
Hi,
Try following Regex
^[a-zA-Z0-9]*$
C#
var regex = "^[a-zA-Z0-9]*$"; var your_text1 = "udaydodiya123" var your_text2 = "uday dodiya $123" var match1 = Regex.Match(your_text1 , regex, RegexOptions.IgnoreCase); var match2 = Regex.Match(your_text2 , regex, RegexOptions.IgnoreCase); if (!match1.Success) { Console.WriteLine("First Expression Does Not Match"); } else { Console.WriteLine("First Expression Match"); } if (!match2.Success) { Console.WriteLine("Second Expression Does Not Match"); } else { Console.WriteLine("Second Expression Match"); }Output :
First Expression Match
Second Expression Does Not Match