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 Coder
    Join Date
    Mar 2005
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    verifying password fields then submit form...

    Here's ya one to help me with...

    When the user clicks the submit button a function should compare the values entered in the password boxes. If the values are the same, the forms data should be submitted. If different alert the user. The forms data should NOT be sent before verifying.

    can you help?


    <html>
    <head>
    <meta http-equiv="Content-Language" content="en-us">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Learning Javascript</title>
    <SCRIPT LANGUAGE="JavaScript">
    <!-- HIDE FROM INCOMPATIBLE BROWSERS
    function chkPassword() {
    if (document.infoForm.txtPass1.value == document.infoForm.txtPass2.value) {
    // FORM SUBMIT CODE???

    else
    //ALERT USER VALUES DOES NOT MATCH

    }
    // STOP HIDING FROM INCOMPATIBLE BROWSERS -->
    </SCRIPT>

    </head>
    <body>
    <form action="mailto:myemailaddress@home.com"
    Method="post" enctype="text/plain" name="infoForm">
    <p>Email: <input type="text" name="txtEmail" size="24"> Password:
    <input type="password" name="txtPass1" size="20"> Verify Password:
    <input type="password" name="txtPass2" size="20"></p>
    <p>
    <input type="submit" value="Submit" name="button_Submit" onclick=chkPassword()>
    <input type="reset" value="Reset" name="button_Reset">
    </p>
    </form>
    </body>
    </html>

  • #2
    Regular Coder
    Join Date
    Oct 2004
    Location
    In front of this computer. (Where else?)
    Posts
    442
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
     
    <html>
    <head>
    <meta http-equiv="Content-Language" content="en-us">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Learning Javascript</title>
    <SCRIPT LANGUAGE="JavaScript">
    <!-- HIDE FROM INCOMPATIBLE BROWSERS
    function chkPassword() {
    if (document.infoForm.txtPass1.value == document.infoForm.txtPass2.value) {
    // FORM SUBMIT CODE???
    return true
    else
    //ALERT USER VALUES DOES NOT MATCH
    alert("Values do not match")
    return false
    }
    // STOP HIDING FROM INCOMPATIBLE BROWSERS -->
    </SCRIPT>
    
    </head>
    <body>
    <form action="mailto:myemailaddress@home.com"
    Method="post" enctype="text/plain" name="infoForm">
    <p>Email: <input type="text" name="txtEmail" size="24"> Password:
    <input type="password" name="txtPass1" size="20"> Verify Password:
    <input type="password" name="txtPass2" size="20"></p>
    <p>
    <input type="submit" value="Submit" name="button_Submit" onclick=chkPassword()>
    <input type="reset" value="Reset" name="button_Reset">
    </p>
    </form>
    </body>
    </html>

    When a form action calls a javascript function, it checks the return value
    "return true" submits the form, "return false" cancels submission.

    BTW - Next time you want to post some code, make sure it's wrapped within Code Tags.
    Last edited by tboss132; 03-08-2005 at 03:32 PM.
    Tomorrow is the first day of the rest of your life... What have you done today?
    Tutorials
    Web: w3schools, htmldog General tips: Hardware, Networking


  •  

    Posting Permissions

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