Friday, October 8, 2010

Regex for Valid Decimal

// The value should be in the Format 0.00 for this use below method
///
/// Determines whether [is valid decimal] [the specified temp].
///

/// The temp.
///
/// true if [is valid decimal] [the specified temp]; otherwise, false.
///

public static bool IsValidDecimal(string temp)
{
bool isValidCurrency = true;
Regex regularExp = new Regex(@"^\d{0,9}(\.\d{1,2})?$");
if (!regularExp.IsMatch(temp))
{
isValidCurrency = false;
}
return isValidCurrency;
}

No comments:

Post a Comment