Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Validate an Email address of a text box

FatalsniperFatalsniper Member Posts: 55
Hi there,

I need to validate an email address from a text box and I dont' know if there's some function that does that or I have to create one. if you know it or have an idea, it is welcome...

Thanks a lot...

Comments

  • SouldrinkerSouldrinker Member Posts: 143
    hi,

    in first step I would check the chars, if there is no @ or no . - the eMail adress is not valid.

    The second step is much more tricky - just send a testmail to this user with sender-adress xyz. Now you create a cronjob that receives the mails for the mail adress xyz and checks for mailer daemon messages, if there are any for some adresses - they will be marked as not valid eMail-adresses.

    I suggest, just using step 1 is much more easier

    best regards,

    sebastian mohrenstecher
    executive secretary
    net::allies

    www.net-allies.de
    [email protected]

  • FatalsniperFatalsniper Member Posts: 55
    I think I'll just try step 1

  • locodudelocodude Member Posts: 28
    : I think I'll just try step 1
    :
    :

    Personally I'd perform the validation on the client-side instead of on the server.
    Here's some Javascript I've used to achieve this:

    var spos=emailStr.indexOf("@); /*emailStr is the e-mail address*/
    var rspos=emailStr.lastIndexOf("@);
    var rppos=emailStr.lastIndexOf(".");
    if((spos<1)||((rppos-rspos)<2))
    {
    alert("That is not a correct e-mail address!");
    return false;
    }else{
    return true;
    }



  • SchoberSchober Member Posts: 2
    you might as well use a regular expression in PHP
    I use this one in our guestbook:
    if(ereg("^[_a-zA-Z0-9-]+(.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+.)+([a-zA-Z]{2,4})$",$email))
    {//email-adress is correct - continue...}

  • TurfTurf Member Posts: 4
    Doing the validation with Javascript does not obviate the need to do it Server side with PHP. Remember, you never trust user supplied data. It is very easy to bypass any validation performed by Javascript and submit munged data. Javascript validation is a convenience only, to simplify data correction from the users standpoint.
  • Justin BibJustin Bib USAMember Posts: 0

    ___ [ http://forcoder.org ] free ebooks and video tutorials about < Swift Python R C++ JavaScript Visual Basic .NET PL/SQL Visual Basic Go C# Scratch Java PHP Delphi C Ruby Perl Assembly MATLAB Objective-C Alice Apex Prolog Crystal Rust Julia Transact-SQL Ada Kotlin Logo D Awk LabVIEW F# Lisp Scala Erlang Fortran Hack VBScript ABAP SAS ML Lua Clojure Bash Dart COBOL Scheme FoxPro /> __

Sign In or Register to comment.