Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Text.RegularExpressions;
- namespace exam2tsp
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- Regex reg = new Regex("[^a-z6-9]");
- private void button1_Click(object sender, EventArgs e)
- {
- string user = textBox1.Text;
- string pass = textBox2.Text;
- if (user.Length < 5 || user.Length >8)
- {
- MessageBox.Show("Username must be at least 5 characters long, up to 8");
- textBox1.Clear();
- }
- else if (Char.IsNumber(user[0]))
- {
- MessageBox.Show("Username should start with a small latin letter");
- textBox1.Clear();
- }
- else if(pass.Length != 4)
- {
- MessageBox.Show("Password must be exactly 4 symbols and end with a question mark (?).");
- textBox2.Clear();
- }
- else if (textBox2.Text[3] != '?')
- {
- MessageBox.Show("The password must always end with a question mark (?).");
- textBox2.Clear();
- }
- else if (reg.Matches(textBox1.Text).Count > 0 )
- {
- MessageBox.Show("The username must contain only digits from 6 to 9 and small latin letters! ");
- textBox1.Clear();
- }
- else
- {
- MessageBox.Show("success");
- /*
- this.Hide();
- Form2 Data = new Form2();
- form2.Show();
- */
- //login is successful and leads to another menu which i haven't made yet
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement