SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot LunaC's Avatar
    Join Date
    Feb 2001
    0 Post(s)
    0 Thread(s)
    I have a contest running at my website and have everything going fine except that I'd like to be able to validate the email when they sign up for the newsletter.

    The newsletter sign-up is ran through the usual cgi form thingy and have that if they don't enter an email address they get sent to the "missed email" page but would really like to be able to check for common typo's.

    I tried adding a Javascript into it and it didn't work at all... any ideas?

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    San Diego, CA
    0 Post(s)
    0 Thread(s)
    This should get you started with doing it in Javascript:


    <form name="form1">
    <input type="text" name="email">
    <input type="button" onClick="check_email(); " name="checkit" value="Checkit">

    <script language="JavaScript">

    function check_email() {
    var str = document.forms[0].email.value;
    var emailexp = /^[a-z][\_\-a-z_0-9\.]+@[\-a-z_=>0-9\.]+\.[a-z]{2,3}$/i;
    if(str.match(emailexp)) {
    alert("Email Good");
    else {
    alert("Email Bad");
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts