Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    return false and formmail problem

    Hi Guys...

    I'm trying to write a form, and wrote a function to validate the email address. It recoginizes if the email address is incorrect, but yet it still tries to send the form... How can I fix it?

    Here's the code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <meta name="keyword" content="reviews, theater advice, theatre advice, shows, plays, broadway, musicals, theatre," />
    <meta name="description" content="Theater Networking site to spread people's opinions and reviews." />
    <title>Theater Advisor :: Bringing the people's reviews to you. </title>
    <style type="text/css">
    body {text-align: center;}

    #form {text-align: center;
    font-family: Helvetica, Arial, sans-serif;
    }

    p {text-align: center;
    font-family:Helvetica, Arial, sans-serif;
    margin-bottom: 50px;}

    #logo {margin-top: 150px;
    margin-bottom: 0px;}
    #font {font-size: 36px;

    }
    </style>
    <script language="javascript" type="text/javascript">
    <!--
    function isEmpty(str) {
    var empty = (str == null || str == "") ? true : false
    return empty
    }



    function validEmail(email) {

    var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
    if(pattern.test(email))
    {

    return true
    } else {

    alert("Please enter a valid e-mail address");
    document.newsletter.email.focus();
    return false
    }
    }

    //-->
    </script>

    </head>

    <body>
    <p id="logo"><img src="images/theateradvisorlogo.jpg" height="199" width="414" alt="Theater Advisor Logo" /></p>
    <p><span style="color:#f6aa19;">Real People.</span> <span style="color:#a41f20;">Honest Opinions.</span></p>
    <p id="font">Coming Soon!</p>

    <p>Send us your e-mail and we'll let you know when to check back!</p>

    <div id="form">
    <form name="newsletter" id="newsletter" action="formmail.php" method="post" onSubmit="validEmail(document.newsletter.email.value)">
    <table>
    <tr>
    <td><input type="hidden" name="recipient" value="beverleyviljoen02@yahoo.com"></td>
    <td>
    <input type="hidden" name="redirect" VALUE="http://www.theateradvisor.com/thanks.html"> </td>
    </tr>

    <tr>
    <td>Find out when we launch!</td>
    <td><input type="text" name="email" id="email" size="50" onFocus="if(this.value == 'Enter your email and press submit.') { this.value = ''; }" value="Enter your email and press submit." /></td>

    <td valign="top" colspan="2" align="center">
    <input type="submit" />
    </td>
    </tr>
    </table>
    </form>
    </div>

    </body>
    </html>



    Here's the website
    http://www.itsjustmelive.com/Theater%20Advisor/

    Can you help?
    Thanks

  • #2
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,108
    Thanks
    38
    Thanked 498 Times in 492 Posts

    Lightbulb Something to try ...

    Try changing this:
    Code:
    <form name="newsletter" id="newsletter" action="formmail.php" method="post"
     onSubmit="validEmail(document.newsletter.email.value)">
    To this:
    Code:
    <form name="newsletter" id="newsletter" action="formmail.php" method="post"
     onsubmit="return validEmail(document.newsletter.email.value)">


  •  

    Tags for this Thread

    Posting Permissions

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