Generic Custom Validation Control

 using System;
using System.Text.RegularExpressions;

public class CustomValidations
{
public CustomValidations()
{
}


///


/// This method is used for validating  the string and returns
///   true , if the string contains alphabets otherwise _
false.
///

///
/// string : Regular Expression to be _
checked
///
///
/// string : string to be validated
///
///
/// bool
///

public static bool isValid(string _
regExpression,string stringToCheck)


return !(new Regex(regExpression)). _
IsMatch(stringToCheck);
}

}


Some Regular Expression tried

is Alphabetic :   [^a-zA-Z]
is ValidString :   [\']
is ValidNumber :   [^0-9\\-\\s\\)\\(]
is ValidEmail :   [^a-zA-Z0-9\\\\_\\.\\@]

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish