function ValidateEntries(curForm) { var EmailAddress; var Comments; EmailAddress = String(curForm.EmailAddress.value); Comments = String(curForm.EmailAddress.value); //check for length of at least 5 if (EmailAddress.length < 5) { alert ("The minimum length for a valid email address is 5. Please modify your email address entry."); return false; } else var CharacterIndex; //check for @ symbol in the string, but not sooner than the 2nd character CharacterIndex = EmailAddress.indexOf('@'); if (CharacterIndex == -1) { alert ("A valid email address must contain the '@' character. Please modify your email address entry."); return false; } else if (CharacterIndex < 1) { alert ("A valid email address cannot have the '@' character sooner than the second position. Please modify your email address entry."); return false; } else //check for the . sign in the string but not sooner than the fourth character CharacterIndex = EmailAddress.indexOf('.'); if (CharacterIndex == -1) { alert ("A valid email address must contain the '.' character. Please modify your email address entry."); return false; } else if (CharacterIndex < 3) { alert ("A valid email address cannot have the '.' character sooner than the fourth position. Please modify your email address entry."); return false; } else if (Comments.length > 255) { alert ("Please limit your comments to 255 characters."); curForm.Comments.focus(); return false; } else return true; }
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||