Advertisement
blodwen_argent

Untitled

Oct 28th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.02 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Text.RegularExpressions;
  11.  
  12.  
  13. namespace exam2tsp
  14. {
  15.     public partial class Form1 : Form
  16.     {
  17.         public Form1()
  18.         {
  19.             InitializeComponent();
  20.         }
  21.  
  22.         Regex reg = new Regex("[^a-z6-9]");
  23.  
  24.         private void button1_Click(object sender, EventArgs e)
  25.         {
  26.             string user = textBox1.Text;
  27.             string pass = textBox2.Text;
  28.  
  29.             if (user.Length < 5 || user.Length >8)
  30.             {
  31.                 MessageBox.Show("Username must be at least 5 characters long, up to 8");
  32.                 textBox1.Clear();
  33.             }
  34.  
  35.  
  36.             else if (Char.IsNumber(user[0]))
  37.             {
  38.                 MessageBox.Show("Username should start with a small latin letter");
  39.                 textBox1.Clear();
  40.             }
  41.  
  42.             else if(pass.Length != 4)
  43.             {
  44.                 MessageBox.Show("Password must be exactly 4 symbols and end with a question mark (?).");
  45.                 textBox2.Clear();
  46.             }
  47.  
  48.             else if (textBox2.Text[3] != '?')
  49.             {
  50.                 MessageBox.Show("The password must always end with a question mark (?).");
  51.                 textBox2.Clear();
  52.             }
  53.  
  54.             else if (reg.Matches(textBox1.Text).Count > 0 )
  55.             {
  56.                 MessageBox.Show("The username must contain only digits from 6 to 9 and small latin letters! ");
  57.                 textBox1.Clear();
  58.             }
  59.  
  60.          
  61.  
  62.            
  63.             else
  64.             {
  65.                 MessageBox.Show("success");
  66.                 /*
  67.                this.Hide();
  68.                Form2 Data = new Form2();
  69.                form2.Show();
  70.                  */
  71.                 //login is successful and leads to another menu which i haven't made yet
  72.  
  73.             }
  74.        
  75.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement