Results 1 to 2 of 2

Thread: Checking if passwords match on registration.

  1. #1
    Join Date
    Nov 2009
    Posts
    18

    Unhappy Checking if passwords match on registration.

    So, for a simple little example of what I want to do...

    ------------------------------------------------

    REGISTRATION FORM
    <br>
    Desired Username: <input type="text" name="username">
    <br>
    Password: <input type="text" name="password">
    <br>
    Verify pass: <input type="text" name="passwordcheck">

    ------------------------------------------------

    I want to rig up something that will automatically check the values posted in "password" and "passwordcheck" before the form is submitted making sure that they match each other and give a little error message if they don't. Ideally, if they don't match it would also prevent the form from even being submitted. My knowledge of Javascript is pretty basic, in fact it primarily consists of what's covered under the "basic" category in w3schools.com's Javascript tutorial, as well as a very modest understanding of form validation in the "advanced" section of the same site. So I haven't had much luck trying to accomplish this myself.

    Can anyone offer any help? I don't need anything especially fancy (since if it were it would likely be beyond my comprehension at the moment) I just need it to be functional.

  2. #2
    Join Date
    Mar 2010
    Location
    England
    Posts
    1,144
    On the form tag, add the following:

    Code:
    onsubmit="check_passwords( this );"
    in the head section have:

    Code:
    function check_password( vtarget ){
    
       if( vtarget.password.value != vtarget.passwordcheck.value )
            return false;
       else
            return true;
    
    }
    I think thats it.

Similar Threads

  1. CSS & Registration form help
    By behvin in forum Web Design, HTML Reference and CSS
    Replies: 0
    Last Post: 28 Jan 2010, 05:15 PM
  2. Managing Multiple Passwords for Different Sites
    By David Bowley in forum General Questions
    Replies: 1
    Last Post: 30 May 2008, 02:32 PM
  3. Regex match string1 but not string2 - help please
    By lonewolf in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 1
    Last Post: 24 May 2007, 12:49 PM
  4. Order results by closest match
    By kirstybandm in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 1
    Last Post: 18 Jan 2006, 09:35 AM

Posting Permissions

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