Reply
How to prevent signup using free email
Old 02-24-2005, 05:01 PM How to prevent signup using free email
wvmlt's Avatar
Experienced Talker

Posts: 46
I would like to prevent (or make it a little difficult) users signing up using yahoo or hotmail addresses. I have some javascript to check that the format of the email addy is correct, how can I modify it to not allow signups from yahoo and hotmail users? Heres my code:

PHP Code:
<TR
              <
TD vAlign=top align=left width="29%" height=26><B>E-Mail Address:</B><BR
                &
nbsp;</TD>
 

<
script type="text/javascript">
<!--
String.prototype.frmEmail = function () {return /^[^x00-x20()<>@,;:".[\]\x7f-\xff]+(?:\.[^\x00-\x20()<>@,;:\\".[]x7f-xff]+)*@[^x00-x20()<>@,;:".[\]\x7f-\xff]+(?:\.[^\x00-\x20()<>@,;:\\".[]x7f-xff]+)+$/.test(this)}
// -->
</script>
              <TD vAlign=top align=left width="71%" height=26><input type="text" onchange="if (!this.value.frmEmail()) {alert ('That would not appear to be a valid email address.'); this.value=''; this.focus()}" size=34 name=frmEmail> 
                <BR>
                *Valid E-Mail address is required to activate account.</TD>
            </TR> 
wvmlt is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 02-24-2005, 08:46 PM
Phaedrus's Avatar
Ultra Talker

Posts: 271
Location: CA
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'.
__________________
Free Teacher Websites

Last edited by Phaedrus : 02-24-2005 at 09:01 PM.
Phaedrus is offline
Reply With Quote
View Public Profile
 
Old 02-25-2005, 06:05 AM
wvmlt's Avatar
Experienced Talker

Posts: 46
Thanks, I'll give it a shot.
wvmlt is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to How to prevent signup using free email
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11860 seconds with 12 queries