First page Back Continue Last page Image
- function validEmail(email) {
- invalidChars = " /:,;"
- if (email == "") { // cannot be empty
- return false
- } // does it contain any invalid characters?
- for (i=0; i<invalidChars.length; i++) {
- badChar = invalidChars.charAt(i)
- if (email.indexOf(badChar,0) != -1) {
- return false
- }
- } // there must be one "@" symbol
- atPos = email.indexOf("@",1)
- if (atPos == -1) {
- return false
- }
- if (email.indexOf("@",atPos+1) != -1) { // and only one "@" symbol
- return false
- }
- periodPos = email.indexOf(".",atPos)
- if (periodPos == -1) { // and at least one "." after the "@"
- return false
- } // must be at least 2 characters after the "."
- if (periodPos+3 > email.length) {
- return false
- }
- return true
- } // check to see if the email's valid
- An if result of -1 means the target was not found