Posts Tagged email

Spry Email Validation

First you have to include the js and css files for the spry framework. In this example taken from the spry demos we have two files. Both are designed for text fields.

The actual form field will be wrapped in a div or span tag with an id. Any messaging then gets its own span class within the div.

Below the form on the page, the following scripting is added. This will validate that there is a correct email typed into the text field. Validating on change checks the field on each character entered. For emails it would be better to validate on blur. The user will not get constant reminders as they type.

Notice that there's no Regex on the screen. I didn't need any, the Spry framework took care of it.

, ,

1 Comment

Regular Expression for Validating Email Addresses

This is the regular expression I use to validate email addresses:

Thought it might be useful to some folks. Most email validation regular expressions fail to allow all the valid characters before the @ sign (for example, you can have a +, an & slashes, a single quote, =, ?, ^, _, {, }, ~, *).

In ColdFusion, you can test an address with:

In Javascript, you can test with:

In PHP, you can test with: