Примерно так:
protected void Wizard1_NextButtonClick(object sender, WizardNavigationEventArgs e)
{
if (e.CurrentStepIndex == 0)
{
bool IsValidPassword = false;
///
/// Validate user
///
if (!IsValidPassword) e.Cancel = true;
}
}
public bool IsValidPassword
{
get
{
return Valid.password(password.Text) &&
Valid.password(repassword.Text);
}
}
public class Valid
{
public static bool email(string email)
{
string pattern = "[.\\-_a-z0-9]+@([a-z0-9][\\-a-z0-9]+\\.)+[a-z]{2,6}";
Match isMatch = Regex.Match(email, pattern, RegexOptions.IgnoreCase);
return isMatch.Success;
}
public static bool username(string username)
{
string pattern = "[a-zA-Zа-яА-Я0-9]{5,50}";
Match isMatch = Regex.Match(username, pattern, RegexOptions.IgnoreCase);
return isMatch.Success;
}
public static bool password(string password)
{
string pattern = "(^[a-zA-Zа-яА-Я0-9-~!@#$%^&?*]{6,20})$";
Match isMatch = Regex.Match(password, pattern, RegexOptions.IgnoreCase);
return isMatch.Success;
}
public static bool lfName(string LastFirstName)
{
string pattern = "[a-zA-Zа-яА-Я]{2,50}";
Match isMatch = Regex.Match(LastFirstName, pattern, RegexOptions.IgnoreCase);
return isMatch.Success;
}
public static bool probel(string LastFirstName)
{
string pattern = "([\\s])";
Match isMatch = Regex.Match(LastFirstName.Trim(), pattern, RegexOptions.IgnoreCase);
return isMatch.Success;
}
public static bool phone(string phone)
{
string _phone = phone;
_phone = Regex.Replace(_phone, @"[^\d]", "", RegexOptions.Compiled);
string pattern = "([0-9]{10})$";
Match isMatch = Regex.Match(_phone, pattern, RegexOptions.IgnoreCase);
return isMatch.Success;
}
public static bool address(string address)
{
string pattern = "^[a-zA-Zа-яА-Я0-9-.,\\s]{5,300}$";
Match isMatch = Regex.Match(address.Trim(), pattern, RegexOptions.IgnoreCase);
return isMatch.Success;
}
public static bool sity(string sity)
{
string pattern = "^[a-zA-Zа-яА-Я-]{2,40}$";
Match isMatch = Regex.Match(sity.Trim(), pattern, RegexOptions.IgnoreCase);
return isMatch.Success;
}
public static bool index(string index)
{
string pattern = "^[0-9\\s]{3,10}$";
Match isMatch = Regex.Match(index.Trim(), pattern, RegexOptions.IgnoreCase);
return isMatch.Success;
}
}