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
Violeta Popa
NA
137
164.5k
validate a textbox-error provider
Apr 7 2013 7:30 AM
Hi! i want to validate a textbox, where the email is introduces. First i check if the email is too short, and it works, then i try to check if it ends with @yahoo.com or @gmail.com but it doesn't work fine. I guess it's a problem with Substring. Any help? thks.
private void emailTxt_Validating(object sender, CancelEventArgs e)
{
string mesaj = null;
string email = emailTxt.Text;
int lungime = email.Length;
if (lungime < 11)
{
mesaj = "E-mail prea scurt!";
this.errorProvider1.SetError(this.emailTxt, mesaj);
}
else
{
string text = email.Substring(lungime - 12, 10);
if (text != "@yahoo.com" || text != "@gmail.com")
{
mesaj = "E-mail:
[email protected]
sau
[email protected]
!";
this.errorProvider1.SetError(this.emailTxt, mesaj);
}
}
}
Reply
Answers (
1
)
insert delete update options in c#.net and sql server 2008
fingerprint attendance system in c#