www.webdeveloper.com
Results 1 to 5 of 5

Thread: Confirm you email address

  1. #1
    Join Date
    Jul 2003
    Location
    Florida
    Posts
    4

    Lightbulb Confirm you email address

    I'm trying to confirm that the email address and confirm email address are the same. I have enter this code but it always come back with the error message even when the email and confirm email address are the same.

    <script language="javascript" type="text/javascript">
    function Compare(Email1, Email2)
    {if (FrontPage_Form1.Email1.value == FrontPage_Form1.Email2.value)
    {return true;}
    else
    { alert("Your Email Address and Confirm Email Address must be the same.");
    return false;}

    }
    </script>
    </head>
    in the body i have the onsubmit:

    <FORM onsubmit ="Compare (Email1, Email2)" language="JavaScript" METHOD="POST" ACTION="--WEBBOT-SELF--" name="FrontPage_Form1">

    It should compare the two to make sure they are the same and move on to creating the email and confirmation page. If I don't check the two email address just send the email and create the confirmaiton page everything works. Well I mean they can enter two different email but the email goes out and the confirmation page is created.

    PLEASE Help. This is my first page.

  2. #2
    Join Date
    May 2003
    Location
    Mordor
    Posts
    454
    by the looks of things,

    Email1 and Email2 are text boxes inside your form.

    The problems I can see are...

    where you say onsubmit="Compare(Email1,Email2);", The terms Email1 and Email2 don't mean anything by themselves. You might try "Compare(this.Email1,this.Email2)" or "Compare(FrontPage_Form1.Email1,FrontPage_Form1.Email2)"

    in your function Compare(Email1,Email2), you don't actually use the two arguments at all (even though you have FrontPage_Form1.Email1.value, etc) so the function is probably not acting the way you think it is (although it will probably work due to the coincidental fact that the element names are the same. You could change the first line to
    Code:
    if (Email1.value == Email2.value)

  3. #3
    Join Date
    Jul 2003
    Location
    Florida
    Posts
    4
    Ok I've changed the onsubmit to include the
    onsubmit ="Compare(FrontPage_Form1.Email1, FrontPage_Form1.Email2)"

    Are you saying next that:
    function Compare(FrontPage_Form1.Email1, FrontPage_Form1.Email2)

    should be more like

    function Compare(this).

    and the code below the function:
    {if (Email1.value == Email2.value)
    {return true;}
    else
    { alert("Your Email Address and Confirm Email Address must be the same.");
    return false;}

    }
    </script>
    </head>

    This still comes back with an error when the two emails are the same. Sorry I know it's hard to work with people new to this. But thank you I've worked all week end.

  4. #4
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta name="Content-Script-Type" content="text/javascript">
    <title>Example</title>

    <style type="text/css">
    <!--
    label {display:block; margin:1em 0em}
    input {display:block}
    -->
    </style>

    <script type="text/javascript">
    <!--
    String.prototype.isEmailAddress = function () {return this.match(/^[^\x00-\x20()<>@,;:\\".[\]\x7f-\xff]+(?:\.[^\x00-\x20()<>@,;:\\".[\]\x7f-\xff]+)*\@[^\x00-\x20()<>@,;:\\".[\]\x7f-\xff]+(?:\.[^\x00-\x20()<>@,;:\\".[\]\x7f-\xff]+)+$/)}
    // -->

    function verify (form) {if (form.address.value != form.confirm.value) {alert('The two addresses do not match.'); return false}}
    </script>

    <form action="" onsubmit="return verify(this)">
    <div>
    <label>Email Address<input name="address" type="text" onchange="if (!this.value.isEmailAddress()) {alert('That would not appear to be a valid email address.'); this.value=''; this.focus()}"></label>
    <label>Confirm Address<input name="confirm" type="text" onchange="if (!this.value.isEmailAddress()) {alert('That would not appear to be a valid email address.'); this.value=''; this.focus()}"></label>
    <button type="submit">Submit</button>
    </div>
    </form>
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  5. #5
    Join Date
    Apr 2003
    Location
    Nevada
    Posts
    411
    Originally posted by Charles
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta name="Content-Script-Type" content="text/javascript">
    <title>Example</title>

    <style type="text/css">
    <!--
    label {display:block; margin:1em 0em}
    input {display:block}
    -->
    </style>

    <script type="text/javascript">
    <!--
    String.prototype.isEmailAddress = function () {return this.match(/^[^\x00-\x20()<>@,;:\\".[\]\x7f-\xff]+(?:\.[^\x00-\x20()<>@,;:\\".[\]\x7f-\xff]+)*\@[^\x00-\x20()<>@,;:\\".[\]\x7f-\xff]+(?:\.[^\x00-\x20()<>@,;:\\".[\]\x7f-\xff]+)+$/)}
    // -->

    function verify (form) {if (form.address.value != form.confirm.value) {alert('The two addresses do not match.'); return false}}
    </script>

    <form action="" onsubmit="return verify(this)">
    <div>
    <label>Email Address<input name="address" type="text" onchange="if (!this.value.isEmailAddress()) {alert('That would not appear to be a valid email address.'); this.value=''; this.focus()}"></label>
    <label>Confirm Address<input name="confirm" type="text" onchange="if (!this.value.isEmailAddress()) {alert('That would not appear to be a valid email address.'); this.value=''; this.focus()}"></label>
    <button type="submit">Submit</button>
    </div>
    </form>
    you are truely crazy, where did you come up with that?!?! and can you explain it to me please really... I don't know the first thing about that script, and I love javascript.
    WARNING: non-exposure to the Son can cause burning!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles