Putting some of our basics together, let's try to write a simple Actionscript email validator. What are the criteria for an email address to be valid?
Well at first glance, here are some fairly basic rules:
- At least one alphanumeric character to start
- Followed by an '@' symbol (and no more than one of them in the whole address)
- Followed by at least one more alphanumeric character
- Then a '.' character
- Either 2 or 3 alphanumeric characters after the final "."
- No spaces
When you're writing code, it's a good idea to write down the requirements before you start coding to make sure that you've thought of everything, and to be sure that you're familiar with all of the required actions.
Here's a working example in Flash, try entering an email address:
| Attachment | Size |
|---|---|
| emailValidate.fla | 51.5 KB |