I am creating an application with windows forms checking the credentials. The username needs to be of the format "domain name"\"user".
I am getting an error with the code. How can I correct it
private void textBoxUsername_TextChanged(object sender, EventArgs e)
{
try
{
buttonLogin.Enabled = textBoxUsername.Text != "" && textBoxPassword.Text != "" ? true : false;
TextBox textBox = sender as TextBox;
string userName = textBox.Text;
string DomainStyleLogin = "@/^[a - zA - Z][a - zA - Z0 - 9 -]{ 1,61}[a-zA-Z]\\.[a-zA-Z]{2,}$/";
bool isMatched = Regex.IsMatch(userName, DomainStyleLogin);
if (!isMatched)
{
MessageBox.Show("Invalid Login Format");
}
else
{
MessageBox.Show("Login Successfully");
}
}
catch(Exception ex)
{
MessageBox.Show("Something went wrong: " + ex.ToString());
}
}