Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1284
  • Last Modified:

How to check if a string contains strictly Letters and/or Numbers (ASP.NET)

Hello all,

This should be a simple question.  I would like to do a boolean test to ensure that a string contains letters or numbers or both.  Incase that is not clear, it may not contain any other character other than a letter or number.  Is there such a function in ASP.NET?


Please advise,

-TH
0
travishaberman
Asked:
travishaberman
  • 2
  • 2
1 Solution
 
Fahad MukhtarDistinguished EngineerCommented:
VB.Net or c#?
0
 
travishabermanAuthor Commented:
You know something.. I know this sounds stupid - But I don't even know.. I am fairly decent with C++ and this is my first time ever writing anything in a language like this..  I am working in the ASP "WEB MATRIX" .. Does that help?
0
 
ozoCommented:
If Not Regex.IsMatch( String, "[^A-Za-z0-9]" ) Then
   
End If
0
 
travishabermanAuthor Commented:
Thank you much...!
0
 
Fahad MukhtarDistinguished EngineerCommented:
its C# at the moment: you can convert it to vb.net

foreach (Char c in s.ToCharArray() )
      {
      if (!Char.IsLetter(c))
           break; // non letter charactar
      }
            
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now