I think you could just check for the strings 'yahoo' or 'hotmail' in the email address. So here's what you do:
put this inside the <head> tags:
Code:
<script type="text/javascript">
var reEMail=/^\w[\w\-\.]+\@\w[\w\-]+(\.\w[\w\-]+)+$/;
function _checkIt(re, field, msg, mode) {
if (!re.test(field.value)) {
_alertIt(msg, mode);
if (field.select) {
field.select();
}
if (field.focus) {
field.focus();
}
return (mode && mode==1)?true:false;
}
return true;
}
function _alertIt(msg, mode) {
if (mode) {
totalAlert+=msg+"\n";
}
else {
totalAlert="";
alert(msg);
}
}
function goodEMail(field, msg, mode) {
if ((field.value.indexOf('yahoo') == -1) && (field.value.indexOf('hotmail') == -1))
{
return _checkIt(reEMail, field, msg, mode);
}
else
{
alert('Yahoo and Hotmail accounts are not allowed');
this.value = '';
this.focus();
return false;
}
}
</script>
Then call it like this:
onchange="return goodEMail(this,'That doesn\'t appear to be a valid email address')"
I can't take credit for the functions, they're from FormGuard at yxScripts.com. I just modified it to find 'yahoo' and 'hotmail'.
Last edited by Phaedrus : 02-24-2005 at 09:01 PM.
|