Email Validate with exclude

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • xxnonexnonexx@tampascanner.info

    Email Validate with exclude

    I am looking to do some email validation and many of the scripts I've located
    online are great basic email validators.

    They check to see that the email address is something along the lines of
    somethin@a_vali d_host.at_a_valid_tld

    Thats great, looking for that, BUT

    I then want to EXCLUDE certain domains, ie: webmail hosts, or what ever hosts I
    add to a list.

    I want to work this with my basic update form which gets sent via the a CGI
    script form mail item

    User fills out form
    clicks submit
    JS checks to see if its a valid email address AND NOT a webmail or other
    excluded hosts address. If so then submits via my normal formmail.pl script.

    Any one already invented this?

    Thanks in advance!


    ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
  • Randy Webb

    #2
    Re: Email Validate with exclude

    xxnonexnonexx@t ampascanner.inf o wrote:
    [color=blue]
    > I am looking to do some email validation and many of the scripts I've located
    > online are great basic email validators.
    >
    > They check to see that the email address is something along the lines of
    > somethin@a_vali d_host.at_a_valid_tld
    >
    > Thats great, looking for that, BUT
    >
    > I then want to EXCLUDE certain domains, ie: webmail hosts, or what ever hosts I
    > add to a list.
    >
    > I want to work this with my basic update form which gets sent via the a CGI
    > script form mail item
    >
    > User fills out form
    > clicks submit
    > JS checks to see if its a valid email address AND NOT a webmail or other
    > excluded hosts address. If so then submits via my normal formmail.pl script.
    >
    > Any one already invented this?[/color]

    And if JS is disabled? Meaning, you should be double checking on the
    server anyway. But, you can exclude by host simply by checking for the
    indexOf('domain ToAvoid') and if they are in array then you can loop
    through the array:

    var nonAccepted;
    var blockedDomains = new Array('','',''. ......);
    bDL = blockedDomains. length;
    for (var i=0;i<bDL;i++){
    if (domainName == blockedDomains[i]){
    alert('Blocked Domain');
    nonAccepted = true;
    }
    }

    And then at the end you check nonAccepted and if its true, you return
    false to the onsubmit handler and not submit the form.

    --
    Randy
    comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly

    Comment

    • ASM

      #3
      Re: Email Validate with exclude



      xxnonexnonexx@t ampascanner.inf o a ecrit :[color=blue]
      >
      > I am looking to do some email validation and many of the scripts I've located
      > online are great basic email validators.
      >
      > They check to see that the email address is something along the lines of
      > somethin@a_vali d_host.at_a_valid_tld
      >
      > Thats great, looking for that, BUT
      > I want
      > User fills out form
      > clicks submit
      > JS checks to see if its a valid email address AND NOT a webmail or other
      > excluded hosts address. If so then submits via my normal formmail.pl script.
      >
      > Any one already invented this?[/color]

      if you have a list of urls or domains you insert it in your JS
      and it is not a good idea because anyone can read it

      hate_hosts = 'aol.com,xxxnon exnoneexx,tampa scanner';

      function submiter() {
      var foo = document.myForm .theEmail.value ;
      // code you have to verify url
      var hate = hate_hosts.spli t(','); // hate_hosts -> becomes new array
      var ok=true; // or nothing if 'ok' exists in precedent code
      if(ok)
      for(var i=0;i<hate.leng th;i++)
      if(foo.toString ().indexOf(hate[i])>=0) {
      ok=false;
      alert('This host "'+hate[i]+'" is not accepted');
      }
      return ok;
      }
      </script>
      <form name="myForm" action="page.ht m" onsubmit="retur n submiter();">

      submiter() must return true or false
      so take care that you have to arrange your code to obtain in its end
      the right command
      [color=blue]
      > Thanks in advance![/color]

      anyway JS yould only be an help
      and the form must be submitted if JS is disabled

      --
      *************** *************** *************** **********
      Stéphane MORIAUX et son vieux Mac
      *************** *************** *************** **********

      Comment

      • Stephen Chalmers

        #4
        Re: Email Validate with exclude


        <xxnonexnonexx@ tampascanner.in fo> wrote in message news:gqrba15m77 4hushkl91mnp68c 8j3cise43@4ax.c om...[color=blue]
        > I am looking to do some email validation and many of the scripts I've located
        > online are great basic email validators.
        >
        > They check to see that the email address is something along the lines of
        > somethin@a_vali d_host.at_a_valid_tld
        >
        > Thats great, looking for that, BUT
        >
        > I then want to EXCLUDE certain domains, ie: webmail hosts, or what ever hosts I
        > add to a list.
        >
        > I want to work this with my basic update form which gets sent via the a CGI
        > script form mail item
        >
        > User fills out form
        > clicks submit
        > JS checks to see if its a valid email address AND NOT a webmail or other
        > excluded hosts address. If so then submits via my normal formmail.pl script.
        >
        > Any one already invented this?
        >[/color]

        No, but I've made a simple addition to an existing script. It tests the basic address format without searching
        for illegal characters, giving a descriptive message of any error. Then it checks for unwanted domains with
        any suffix: .fr or co.uk etc, so just add basic names to the list. It picks-up .....@mail.unWa nted.etc. It
        will not pick-up yahooLover@anAc ceptedHost.etc or xxx@hotmailHate rs.etc

        Having said that, I expect that most typos are undetectable in that they don't break the basic format. Also,
        you cannot expect realistically to detect all webmail hosts, and it may not be too tactful to tell a user that
        you're not enamoured of his/her email address.

        <script type='text/javascript'>

        function emTest(emString , showMessage)
        { // S Chalmers 2005

        var badHosts=["usa","msn","ho tmail","yahoo", "pointedEar s"];

        var emaData=


        /\,/, false, "Comma (,) found",
        /\s/, false, "Spaces not allowed",
        /@/, true, "No @ sign",
        /@.*@/, false, "More than one @",
        /^@/, false, "Nothing preceding @",
        /\.@/, false, "@ preceded by '.'",
        /@\./, false, "@ followed by '.'",
        /@.+\./, true, "No '.' anywhere after @",
        /\.\./, false, "=>..",
        /^\./, false, "Cannot start with '.'",
        /\.$/, false, "Cannot end with '.'",
        /.+\.[a-z]{2,}$/i, true, "Must end with 2 or more letters"
        ];
        var ok=true, dl=emaData.leng th, hl=badHosts.len gth;

        emString=emStri ng.replace(/^\s+|\s+$/g,'');

        for(var i=0; i<dl && ( emaData[i].test( emString ) ^ !emaData[i+1] ); i+=3)
        ;

        if(i!=dl)
        {
        ok=false;
        if(showMessage)
        alert("Error in format of e-mail address:\n\n" + emString + "\n\n" + emaData[i+2]);
        }
        else
        {
        for(var j=0; j<badHosts.leng th && !new RegExp("[@.]"+badHosts[j]+"\\.","i").tes t(emString); j++)
        ;

        if(j!=hl)
        {
        ok=false
        if(showMessage)
        alert("Excluded mail host [ "+badHosts[j]+" ]");
        }
        }
        return ok;
        }

        </script>

        <FORM onsubmit="retur n false">
        <input size="50" type="text" name='ema'><BR>
        <input type="button" onclick="emTest (this.form.ema. value, true)" value='TEST'>
        </FORM>

        --
        Stephen Chalmers http://makeashorterlink.com/?H3E82245A

        547265617375726 520627572696564 206174204F2E532 E207265663A2054 51323437393134


        Comment

        • xxnonexnonexx@tampascanner.info

          #5
          Re: Email Validate with exclude

          On Wed, 08 Jun 2005 00:20:12 +0200, ASM <stephaneOTEZ_M OImoriaux@wanad oo.fr>
          wrote:
          [color=blue]
          >
          >if you have a list of urls or domains you insert it in your JS
          >and it is not a good idea because anyone can read it[/color]

          Thanks for the script. I work thru several to meet my needs.
          [color=blue]
          >anyway JS yould only be an help
          >and the form must be submitted if JS is disabled[/color]

          No or disabled JS sent to a page that states you must enable ..... otherwise
          they will not be able to submit the form which is a required part of the
          registration.

          Thanks again for the input, and to all that replied so far. All very helpful.


          ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
          http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
          ----= East and West-Coast Server Farms - Total Privacy via Encryption =----

          Comment

          • xxnonexnonexx@tampascanner.info

            #6
            Re: Email Validate with exclude

            On Tue, 07 Jun 2005 17:48:54 -0400, Randy Webb <HikksNotAtHome @aol.com> wrote:
            [color=blue]
            >And if JS is disabled?[/color]

            They will be sent to a page stating NO JS they can not complete the next step.
            [color=blue]
            > Meaning, you should be double checking on the
            >server anyway[/color]

            I would LOVE to, but I am stuck with a host who has selected the formmail script
            thats allowed, and thats it. No other formmail scripts are allowed. Attempting
            to add your own risks termination of the account. I understand the issue with
            abuse/hijack SPAM etc., so thats the breaks. Other domains on other hosts have
            had their formmail abilities totally removed, scripts for that not allowed, none
            provided by host.
            [color=blue]
            >. But, you can exclude by host simply by checking for the
            >indexOf('domai nToAvoid') and if they are in array then you can loop[/color]

            Thanks for the info greatly appreciated.

            ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
            http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
            ----= East and West-Coast Server Farms - Total Privacy via Encryption =----

            Comment

            • xxnonexnonexx@tampascanner.info

              #7
              Re: Email Validate with exclude

              On Wed, 8 Jun 2005 01:56:25 +0100, "Stephen Chalmers" <ignoring@lycos .co.uk>
              wrote:[color=blue]
              >you cannot expect realistically to detect all webmail hosts, and it may not be too tactful to tell a user that
              >you're not enamoured of his/her email address.[/color]

              It may not be "too tactful" but this is the name of the game for this situation.
              I've asked politely do not submit yahoo, hotmail, gmail etc.. I still get them,
              and reject them. Then I get the nasty email, > /dev/null. You can play by the
              rules or you will not be allowed to join. One of those rules is that a real
              email address must be used not some address at yahoo, hotmail, gmail etc. that
              any user can create 50,000 of them at a time.

              Thanks for the input and script.


              ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
              http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
              ----= East and West-Coast Server Farms - Total Privacy via Encryption =----

              Comment

              Working...