Just for messin' with the people suggesting regexes, you could also do it programatically:
(I'm kinda suggesting you don't know JavaScript that well)
function validateEmail (email) {
// Checks if whatever variable submitted is a string.
// This line is NOT useful if you're sure of whatever being sent to the function,
// but otherwise it'll save your ass for a runtime error.
if (email.constructor != String) return false;
// I'm not sure the search patterns are 100 % (they probably ain't),
// but the @'s should make the search less generic.
var emailsNotAllowed = ["@aol.com", "@hotmail.", "@live.", "@gmail.", "@google.", "@yahoo."];
// Convert the email address to lower case, so you're sure nothing is going wrong with the patterns.
email = email.toLowerCase();
// Loop through all the patterns, and check if one of them matches the email address provided.
for (var i = 0; i < emailNotAllowed.length; i++) {
// The indexOf method will return zero if the string could not be found.
// Otherwise, it will return a positive number, which in JavaScript validates to a true condition.
if (email.indexOf(emailsNotAllowed[i])) {
alert("No Hotmail, Gmail, Yahoo or AOL emails are allowed!");
return false;
}
}
}
Hope it explains itself ;)
As also suggested, a check should be performed server side as an absolute minimum, otherwise you'll have no security. But, for usability, a client side check first is also good.