TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mark Fenech
NA
82
68.9k
C# Validation
May 9 2011 10:08 AM
I am validating some textboxes, so when i press button if validation is ok itt will do its act this is my code dont know why it isnt working. anyhelp please:
private void button1_Click(object sender, EventArgs e)
{
if (!Regex.IsMatch(Username_txt.Text, @"^[a-zA-Z]{1,25}$") && Username_txt.Text.Length > 25 && (Username_txt.Text == String.Empty))
{
MessageBox.Show("Error in username");
}
else if (!Regex.IsMatch(name_txt.Text, @"^[a-zA-Z]{1,25}$") && name_txt.Text.Length > 25 && (name_txt.Text == String.Empty))
{
MessageBox.Show("Error in surname");
}
else if (!Regex.Match(email_txt.Text, @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*").Success)
{
MessageBox.Show("Incorrect Email Address");
}
else if (remail_txt.Text != email_txt.Text)
{
MessageBox.Show("Emails do not match");
}
else if (!Regex.IsMatch(pass_txt.Text, @"^[a-zA-Z]{1,25}$") && pass_txt.Text.Length > 25 && pass_txt.Text == String.Empty)
{
MessageBox.Show("Incorrect password");
}
else
{
db.registerUser(Username_txt.Text, pass_txt.Text, name_txt.Text, surname_txt.Text, email_txt.Text, rMale, rFemale);
MessageBox.Show("Data Submitted", "Registration Form Completed", MessageBoxButtons.OK, MessageBoxIcon.Information);
Form1 fm = new Form1();
this.Hide();
fm.Show();
}
}
Reply
Answers (
2
)
Protect by key
WIA, scan without dialog