Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. protected void bRegistration_Click(object sender, EventArgs e)
  2. {
  3.  
  4. if(CheckLogin(tbLogin)& CheckEmail(tbEmail) & CheckPassword(tbPassword,tbRepeatPassword))
  5. {
  6. bRegistration.PostBackUrl = "~/НачальнаяСтраница.aspx";
  7. }
  8.  
  9. }
  10. public bool CheckEmail(TextBox tb)
  11. {
  12. string pattern = @"^(?("")(""[^""]+?""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" +
  13. @"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9]{2,17}))$";
  14.  
  15. string email = tb.Text;
  16.  
  17. if (Regex.IsMatch(email, pattern, RegexOptions.IgnoreCase))
  18. {
  19. return true;
  20. }
  21. else
  22. {
  23. lbEmail.Text = "Некорректный email";
  24. return false;
  25. }
  26.  
  27. }
  28. public bool CheckPassword(TextBox tb1, TextBox tb2)
  29. {
  30.  
  31. if (tb1.Text.Equals(string.Empty))
  32. {
  33. lbPassword.Text = "Введите пароль";
  34. return false;
  35. }
  36.  
  37. if (tb1.Text.Length < 6)
  38. {
  39. lbPassword.Text = "Длина пароля должна превышать шесть символов";
  40. return false;
  41. }
  42.  
  43. if (tb2.Text.Equals(string.Empty))
  44. {
  45. lbPassword.Text = "Повторите пароль";
  46. return false;
  47. }
  48. if (!tb1.Text.Equals(tb2.Text))
  49. {
  50. lbRepeatPassword.Text = "Пароли не совпадают";
  51.  
  52. return false;
  53. }
  54. return true;
  55.  
  56. }
  57. public bool CheckLogin(TextBox tb)
  58. {
  59.  
  60. if (tb.Text.Equals(string.Empty))
  61. {
  62. lblogin.Text = "Введите логин";
  63. return false;
  64. }
  65. return true;
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement