Can't seem to get this to work.

Discussion in 'JavaScript' started by Kierslee, Aug 11, 2006.

  1. #1
    I'm trying to write some javascript that will check the value of a user-entered email address. If the address matches one that I put in the code I want to redirect the customer. If the address does not match the one(s) in my script I want the function to continue to validate the form.

    My problem is the function doesn't seem to care if the email address in the "email" field matches, the re-direct doesn't happen.

    Can anyone make any suggestions to help me fix this?

    Here is the code.


    <script type="text/JavaScript">
    //Script to verify that all necessary information has been added
    function Verify(myForm)
    {
    if (myForm.email.value = (laset@nomail.de))
    {
    window.location="http://www.urlgoeshere.com/missing.html";
    }
    }
    </script>




    <form name="myForm" method="POST" action="http://urlgoeshere" onsubmit="return Verify(this);">
    <input type="hidden" name="website" value="urlgoeshere">
    <input type="hidden" name="subject" value="Product Review">
    <input type="hidden" name="transtype" value="Non-Secure">
    <input type="hidden" name="success" value="http://www.urlgoeshere.com/product-review-success.htm">

    <input type="hidden" name="pagename" value="<?
    if (isset($Product))
    {
    print $Product;
    }
    else
    {
    print "No product selected.";
    }

    ?>">

    <table cellpadding=2 cellspacing=2 border=0 align="left">
    <tr>
    <td colspan=3 align=center><h3>Submit a Product Review</h3><br></td>
    <td rowspan=10 align="left" valign="top">

    <b>Ideas for writing your review</b>
    <li>What was your experience with this product?</li>
    <li>Why did you purchase this product?</li>
    <li>What do you like about this product?</li>
    <li>What do you dislike about this product?</li></td>
    </tr>
    <tr>
    <th align="right">* Product Name/Model</th>
    <td colspan=2><input type="text" name="Model" size="40" maxlength="40"></td>
    </tr>

    <tr>
    <th align="right">* Name</th>
    <td colspan=2><input type="text" name="name" size="40" maxlength="40"></td>
    </tr>
    <tr>
    <th align="right">Organization</th>
    <td colspan=2><input type="text" name="org" size="40" maxlength="40"></td>
    </tr>
    <tr>
    <th align="right">* E-mail Address</th>
    <td colspan=2><input type="text" name="email" size="40" maxlength="40"></td>
    </tr>
    <tr>
    <th align="right">Phone Number</th>
    <td colspan=2><input type="text" name="phone" size="40" maxlength="40"></td>
    </tr>

    <tr>
    <th align="right">* Review Body</th>
    <td colspan=2><textarea name="reviewbody" ROWS=4 COLS=32></textarea></td>
    </tr>

    <tr>
    <td colspan=3 align=center>
    <input type="submit" value="Submit Product Review">
    <br><br><br><br>
    * Required fields.
    </td>
    </tr>

    </table>
    </form>
     
    Kierslee, Aug 11, 2006 IP
  2. ClarkF1

    ClarkF1 Peon

    Messages:
    2
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Have you tried replacing the bracket with single quotation marks???

    if (myForm.email.value = 'laset@nomail.de')
    Code (markup):
     
    ClarkF1, Aug 11, 2006 IP
  3. exam

    exam Peon

    Messages:
    2,434
    Likes Received:
    120
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Try comparing the two instead of assigning the value of one to the other
    if (myForm.email.value == 'laset@nomail.de') {
        alert ('email matched');
    }
    Code (markup):
    Classic new programmer error :)
     
    exam, Aug 12, 2006 IP