-1

Say i'm creating an email list. How would I validate the field to not accept text without the '@' sign?

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Hassassin
  • 21
  • 2
  • http://stackoverflow.com/questions/1710505/asp-net-email-validator-regex/1710535#1710535 – cHao Apr 10 '11 at 09:39

1 Answers1

0

You can check indexOf() method. It will return an integer.

If email.indexOf("@") < 3 Then
MessageBox("Invalid email")
End If

I think this syntax is correct. Not sure ;)

Anuraj
  • 18,859
  • 7
  • 53
  • 79
  • `IndexOf` returns the zero-based position of the string that is found, or -1 if it is not. What is this code supposed to do? – Cody Gray - on strike Apr 10 '11 at 10:03
  • I added 3 because he want to validate Email address. – Anuraj Apr 10 '11 at 10:04
  • But the name portion of an email address can be as short as one character. My email address could be `c@codygray.com`. That would fail your test here. – Cody Gray - on strike Apr 10 '11 at 10:06
  • Hmm thats true. But I thought min 3 characters required before @ symbol. – Anuraj Apr 10 '11 at 10:19
  • Sorry about the insufficient amount of description. I'm a newbie at vb, and I was making an address book in which if the email did not contain "@", a message box would appear saying "Invalid Email". I found out that I needed the Contains or IndexOf Strings. – Hassassin Apr 11 '11 at 20:02