﻿function isEmailAddr(EMailAddr) {
    var EmailAddressRX = /^(.+)@(.+)\.(.+)$/;  // Check for pattern string.string

    var matches = EMailAddr.match(EmailAddressRX);
    if (matches == null) // IT'S BAD TO THE BONE.
        return false;
    // MORE CHECKING MAY BE REQUIRED -
    return true;
}

function submitEmail() {
    var emailForm = document.getElementById("inviteForm");
    var emailAdd = document.getElementById("fromEmail");
    //alert(emailAdd.value);
    if (emailForm != null && emailAdd) {
        if (isEmailAddr(emailAdd.value)) {
            emailForm.submit();
        }
        else {
            var messageLable = document.getElementById('messageLable');
            if (messageLable != null)
                messageLable.innerHTML = "Please enter a valid email address.";
        }
    }
}
