Validate E-mail and restrict domain in jQuery.

Filter e-mail address by domain name and ensure that it is filled out.

HTML

<form id="signup" method="post">
    <input id="email" type="email" placeholder="Your e-mail." />
</form>

JavaScript

$('#email').blur(function() {
    validateEmail($('input').val());
    return false;
});

function validateEmail(email) {
    var re = /^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\@[\w\-\+_]+\.[\w\-\+_]+(\.[\w\-\+_]+)*\s*$/;
    if (re.test(email)) {
        if (email.indexOf('@yourdomain.com', email.length - '@yourdomain.com'.length) !== -1) {
            alert('Valid email.');
        } else {
            alert('Email must be a CE e-mail address (your.name@yourdomain.com).');
        }
    } else {
        alert('Not a valid e-mail address.');
    }
}