Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void bRegistration_Click(object sender, EventArgs e)
- {
- if(CheckLogin(tbLogin)& CheckEmail(tbEmail) & CheckPassword(tbPassword,tbRepeatPassword))
- {
- bRegistration.PostBackUrl = "~/НачальнаяСтраница.aspx";
- }
- }
- public bool CheckEmail(TextBox tb)
- {
- string pattern = @"^(?("")(""[^""]+?""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" +
- @"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9]{2,17}))$";
- string email = tb.Text;
- if (Regex.IsMatch(email, pattern, RegexOptions.IgnoreCase))
- {
- return true;
- }
- else
- {
- lbEmail.Text = "Некорректный email";
- return false;
- }
- }
- public bool CheckPassword(TextBox tb1, TextBox tb2)
- {
- if (tb1.Text.Equals(string.Empty))
- {
- lbPassword.Text = "Введите пароль";
- return false;
- }
- if (tb1.Text.Length < 6)
- {
- lbPassword.Text = "Длина пароля должна превышать шесть символов";
- return false;
- }
- if (tb2.Text.Equals(string.Empty))
- {
- lbPassword.Text = "Повторите пароль";
- return false;
- }
- if (!tb1.Text.Equals(tb2.Text))
- {
- lbRepeatPassword.Text = "Пароли не совпадают";
- return false;
- }
- return true;
- }
- public bool CheckLogin(TextBox tb)
- {
- if (tb.Text.Equals(string.Empty))
- {
- lblogin.Text = "Введите логин";
- return false;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement