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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    May 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Can Any Coders figure this out

    Hey All,
    I'm so deep into this I don't know what I'm doing anymore. I'm trying to use script to confirm an email address. Anyone can correct this code for me?
    Thanks for you help guys!!!

    Code:
    <form id="frmSurvey" name="frmSurvey" onsubmit="javascript: return false; " action="CaptureFrontDatasheetDecide.jsp" method="post"><!-- Begin: Global Form Tags -->
    
      <input type="hidden" value="" name="userAgent"> 
      <input type="hidden" value="y" name="updateFlag"> 
      <input type="hidden" value="n" name="ansQues1IsNo"> <!-- END: Global Form Tags -->
    
      <table style="WIDTH: 200px" cellspacing="1" cellpadding="0" border="1">
        <tbody>
          <tr><td valign="top" align="left"><span style="COLOR: #ffffff; BACKGROUND-COLOR: black">First Name: </span>
              <input type="text" value="($custom2)" name="firstName" AUTOCOMPLETE="OFF">&nbsp;</td>
          </tr>
          <tr><td valign="top" align="left"><span style="COLOR: #ffffff; BACKGROUND-COLOR: black">Last Name: </span>
              <input type="text" value="($custom3)" name="lastName" AUTOCOMPLETE="OFF">&nbsp;</td>
          </tr>
          <tr><td valign="top" align="left"><span style="COLOR: #ffffff; BACKGROUND-COLOR: black">Title: </span>
              <input type="text" value="($custom4)" name="title" AUTOCOMPLETE="OFF">&nbsp; </td>
          </tr>
          <tr><td valign="top" align="left"><span style="COLOR: #ffffff; BACKGROUND-COLOR: black">Company: </span>
              <input type="text" value="($custom5)" name="company" AUTOCOMPLETE="OFF"></td>
          </tr>
          <tr><td valign="top" align="left"><p>Enter E-Mail Address: - 
                <input id="emailadd" onblur="javascript: checkValidEmail() " type="text" size="42" value="($prospectEmail)" name="email" AUTOCOMPLETE="OFF" input=""> 
              </p></td>
          </tr>
          <tr><td valign="top" align="left"><p>Confirm Email Address: - 
                <input id="conemail" onblur="javascript: checkConfirmEmail() " type="text" size="42" value="($custom1)" name="custom1" AUTOCOMPLETE="OFF" input=""> 
              </p></td>
          </tr>
          <tr><td valign="top" align="left"></td>
          </tr>
          <tr><td valign="top" align="left"><p style="MARGIN: 0px" align="right"><span style="COLOR: #ffffff; BACKGROUND-COLOR: black">Address 1: </span>
                <input type="text" value="($custom6)" name="address1" AUTOCOMPLETE="OFF">&nbsp; 
              </p></td>
          </tr>
          <tr><td valign="top" align="left"><p style="MARGIN: 0px" align="right"><span style="COLOR: #ffffff; BACKGROUND-COLOR: black">Address 2: </span>
                <input type="text" value="($custom7)" name="address2" AUTOCOMPLETE="OFF">&nbsp; 
              </p></td>
          </tr>
          <tr><td valign="top" align="left"><p style="MARGIN: 0px" align="right"><span style="COLOR: #ffffff; BACKGROUND-COLOR: black">City: </span>
                <input type="text" value="($custom8)" name="city" AUTOCOMPLETE="OFF">&nbsp; 
              </p></td>
          </tr>
          <tr><td valign="top" align="left"><p style="MARGIN: 0px" align="right"><span style="COLOR: #ffffff; BACKGROUND-COLOR: black">State: </span>
                <input type="text" value="($custom9)" name="state" AUTOCOMPLETE="OFF">&nbsp; 
              </p></td>
          </tr>
          <tr><td valign="top" align="left"><p style="MARGIN: 0px" align="right"><span style="COLOR: #ffffff; BACKGROUND-COLOR: black">Zip: </span>
                <input type="text" value="($custom10)" name="zip" AUTOCOMPLETE="OFF">&nbsp; 
              </p></td>
          </tr>
          <tr><td valign="top" align="left"><p style="MARGIN: 0px" align="right"><span style="COLOR: #ffffff; BACKGROUND-COLOR: black">Daytime Phone: </span>
                <input type="text" value="($custom11)" name="phone" AUTOCOMPLETE="OFF">&nbsp; 
              </p></td>
          </tr>
          <tr><td valign="top" align="left"><input onclick="javascript: doSubmit();return false; " type="button" value="Submit" name=""> </td>
          </tr>
        </tbody>
      </table>
      </td>
      </tr>
    </form>
    <script type="text/javascript">
    function checkValidEmail() {
    email1= document.myform.emailadd.value;
    if (/^([a-z0-9])([\w\.\-\+])+([a-z0-9])\@(([\w\-]?)+\.)+([a-z]{2,4})$/i.test(email1)) {
    }
    else {
    alert ("Invalid Email Address - Please Re-Enter");
    document.myform.emailadd.value = "";
    document.myform.emailadd.focus();
    }
    }
    function checkConfirmEmail() {
    email2 = document.myform.conemail.value;
    if (email2 != email1) {
    alert ("Email addresses do not match - please re-enter!");
    document.myform.emailadd.value = "";
    document.myform.conemail.value = "";
    document.myform.emailadd.focus();
    }
    else { 
    }
    }
    </script>
    Last edited by emd2kick; 05-23-2009 at 03:01 AM.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,863
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Get a copy of firebug for your FF, which may help you to track the errors by yourself.

    PS: Use an input element having type="submit", for submitting your form, otherwise your form will do nothing in the absence of javascript support. You may need to call your validation procedure from the onsubmit attribute of your <form>
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,172
    Thanks
    203
    Thanked 2,549 Times in 2,527 Posts
    email1= document.myform.emailadd.value;

    but your form is named "frmSurvey" not "myform"
    and the element name is "email" (athough you have an id of "emailadd")

    Put these right - i.e. make them consistent, and it will work.


    "To get back my youth I would do anything in the world, except take exercise, get up early, or be respectable." - Oscar Wilde (Irish Poet, Novelist, Dramatist and Critic, 1854-1900)


  •  

    Posting Permissions

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