Creative Juices Bo. Co.

Satisfy Your Thirst For Something Refreshing!

Validating E-Mail and Web Addresses Using Regular Expressions with ColdFusion

Two Useful Form Field Validation Functions

Here are two quick ColdFusion scripts to validate if a user supplied a real e-mail address or website URL using Regular Expressions.

To validate an e-mail address:

<cfif REFindNoCase("^[\w\.-]+@[\w\.-]+\.[a-zA-Z]{2,3}$",form.EMAIL) lt 1>
    <--- E-mail address was not valid.... --->

... and to validate a website url:

<cfif REFindNoCase("^(http://|https://)[\w\.-]+\.[a-zA-Z]{2,3}(/?)$",form.WEBSITE) lt 1>
    <--- Website URL was not valid.... --->

I wanted to post these real quick just so I have them handy, but also you might find them useful as well.