Need help with onSubmit message

Discussion in 'JavaScript' started by lsq, Oct 18, 2005.

  1. #1
    I am not a JavaScript programmer, but I needed to include JavaScript on one page of a Website. The page in question is found at
    http://www.housecallcs.com/pages/virus.htm

    The client requested two things.
    1. If the two email address inputs do not match, a message appears saying that the email addresses must be re-entered.
    2. Once the form is submitted, a confirmation message appears saying that the email address is being added to a list.

    I can do one, or the other, but not both. As is online, the confirmation message appears, but the email addresses are not validated. I have been able to get #1 to work with the following code, but when I add the confirmation alert (not listed below), it doesn't work. Any help will be very much appreciated.

    head code:
    function checkPw(form) {
    email = form.email.value;
    email1 = form.email1.value;

    if (email != email1) {
    alert ("\nYou did not enter the same new email address twice. Please re-enter your email address.")
    return false;
    }
    else return true;
    }

    body code:
    <form onSubmit="return checkPw(this)" name="input" action="http://www.housecallcs.com/gdform.asp" method="get">
    <p><label><span>Email Address:</span></label><input name="email" type="text" size="40"></p>
    <p><label><span>Confirm Email Address:</span></label><input name="email1" type="text" size="40"></p>
    <p><label>Name:</label><input name="name:" type="text" size="40"></p>
    <p><label>Address:</label><input name="address" type="text" size="30"></p>
    <p><label>State:</label><input name="state" type="text" size="2"></p>
    <p><label>Zip:</label><input name="zip" type="text" size="10"></p>
    <p><input type="submit" value="Submit"></p>

    </form>
     
    lsq, Oct 18, 2005 IP
  2. torunforever

    torunforever Peon

    Messages:
    414
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If I understand what you were able to get working when just doing #2, then you give an alert in the original page saying the form was submitted. Wouldn't you agree that it's a little too early to be telling the user the form was submitted when the form still hasn't been submitted?

    You need to reevaluate what you're trying to accomplish with this. If the form has been submitted, the user is on a different page, and it's on that page that you need to give some sort of message. Preferably not an alert, because a simple message in the body of the page would do.
     
    torunforever, Oct 18, 2005 IP
  3. lsq

    lsq Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    How the code listed in the first message of this thread works: the user is asked to enter their email address twice. When the submit button is clicked, javascript checks to see if the two entries are the same. If not, a message appears saying that the entries don't match and need to be re-entered and the form does not submit. If the entries do match, the form is submitted. What I need to know how to add is a second alert message - if the two entries match, and the form is submitted, an alert, or pop-up appear telling the user that the form has been submitted.
     
    lsq, Oct 18, 2005 IP
  4. torunforever

    torunforever Peon

    Messages:
    414
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I understand what you've said, but I think you're going about it the wrong way.

    The user starts off on virus.htm. Once the form is submitted, the user is then on a different page, gdform.asp. It's in that page that you'll need to put the message.
     
    torunforever, Oct 18, 2005 IP
  5. lsq

    lsq Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks for your input. I was wondering about that - but I don't know how to do it, since gdform.asp resides on the server. I send an inquiry to the host (GoDaddy.com), but I haven't heard back yet. If you have anything that would help me, I would appreciate it. Thanks for your time.
     
    lsq, Oct 18, 2005 IP
  6. durango

    durango Guest

    Messages:
    83
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #6
    So, you can not alter gdform.asp? Hmmm.. only thing I can think off of the top of my head is posting to an IFRAME and checking in a javascript if the IFRAME loading is complete. But that won't actually tell you if the script possibly failed. You really need to be able to modify gdform.asp.
     
    durango, Oct 18, 2005 IP