Validating an email-address format in Classic ASP

A regular expression can check whether an entered email address has a plausible structure. It cannot prove that the mailbox exists, accepts mail, or belongs to the visitor. Verification normally requires sending a confirmation message or another application-specific verification step.

Dim re
Set re = New RegExp

The following intentionally practical pattern checks for a non-space local part, one @, and a dotted domain without trying to implement the entire email specification:

Dim email, isValid
Set re = New RegExp
re.Pattern = "^[^\s@]+@[^\s@]+\.[^\s@]+$"
re.IgnoreCase = True
re.Global = False
email = "reader@example.com"
isValid = re.Test(email)
Response.Write isValid

Examples that match this basic format:

reader@example.com, first.last@example.co.in, user+tag@example.org

Examples that fail the basic check:

reader.example.com, reader@, @example.com

Avoid over-restrictive regexes that reject legitimate addresses merely because they contain a plus sign, a long top-level domain, or another valid character your old pattern did not anticipate.


ASP Home






✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer