SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    May 2008
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Checking two passwords match

    I currently have this code (I am using the prototype / scriptaculous JS libraries, b.t.w)
    Code:
                function check_password_match( form, pfix ) {
                    if (form.value == $('password')){
                        $('password2_good').show();
                        $('password2_odd').hide();
                        system_check[ 'password2' ] = true;
                    } else {
                        $('password2_good').hide();
                        $('password2_odd').show();
                        system_check[ 'password2' ] = false;
                    }
                    check_system();   
                }
    But it doesn't work. The part that doesn't work / breaks the script is the $('password') part. How can I tell the script to compare the password in repeat password to that from the first field (called password, which is where the code from above comes from).

    Many thanks,

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,705
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    The form.value doesn't make any sense. Is form a reference to the form itself, or to the password field that you're checking? I'll presume that it's supposed to be the latter, in which case you should change the variable name to be more consistent.

    Anyway, you should be checking $('password').value instead, which contains the value you're wanting to compare against.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

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