{
Random r = new Random();
int a = r.Next(1000000000);
string Expirydate = txt_ExpirationDate.Text;
if (CryptoEngine.IsValidExpiration(Expirydate) == false)
{
Response.Write("<script>alert('Expiry Date not valid');</script>");
}
public bool IsValidExpiration(string ExpiryDate)
{
string[] date = Regex.Split(txt_ExpirationDate.Text, "/");
string[] currentDate = Regex.Split(DateTime.Now.ToString("MM/yyyy"), "/");
int compareYears = string.Compare(date[1], currentDate[1]);
int compareMonths = string.Compare(date[0], currentDate[0]);
//if expiration date is in MM/YYYY format
if (Regex.Match(txt_ExpirationDate.Text, @"^\d{2}/\d{4}$").Success)
{
//if month is "01-12" and year starts with "20"
if (Regex.Match(date[0], @"^[0][1-9]|[1][0-2]$").Success)
{
//if expiration date is after current date
if ((compareYears == 1) || (compareYears == 0 && (compareMonths == 1)))
{
return true;
}
}
}
return false;
}
我在txt_ExpirationDate
中说
它在当前上下文中不存在
我在CryptoEngine.IsValidExpiration
上说
非静态字段需要对象引用