﻿$(document).ready(function() {
    $("#_subscribe").click(function(e) {
        // Prevent submitting form.
        e.preventDefault();

        // Validate email.
        var email = $("#_email").val();
        if (email.length == 0) { alert("Please enter your email."); return; }
        else if (!email.match(/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/)) { alert("Please enter a valid email."); return; }

        // Subscribe the provided email.
        window.location = "lounge.aspx?email=" + encodeURIComponent(email);
    });
});