Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



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

Posts: 46
Trades: 0
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
 
 
Register now for full access!
Old 02-24-2005, 09:46 PM
Phaedrus's Avatar
Ultra Talker

Posts: 271
Location: CA
Trades: 0
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'.
__________________

Please login or register to view this content. Registration is FREE

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

Posts: 46
Trades: 0
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 Search this Thread
Search this Thread:

Advanced Search

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

BB 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.11776 seconds with 12 queries