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 2009
    Posts
    97
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Slidedown box for change password

    Right well, im coding a usercp in php, and i want to add a feature where, when you click on "edit password" a box slides down with the fields "old password, "new password", "retype new password" and it validates the info and checks if they match and if old password is same as one in database.

    How would i go about doing this please?

    KJD.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,919
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    This should give you a start:-

    Code:
    <form name = "myform">
    
    Edit Password <input type = "checkbox" name= "chk1" id = "chk1" onclick = "showboxes()">
    <br><br>
    <div id = "list1" style="display:none">Enter Old Password  <input type = 'text' name = 'oldpass' id = "oldpass"> Enter New Password <input type = 'text' name = 'newpass1' id = "newpass1">
     Confirm New Password <input type = 'text' name = 'newpass2' id = "newpass2" onblur = "validate()"></div>
    </form>
    
    <script type = "text/javascript">
    
    function showboxes() {
    document.getElementById("list1").style.display="block";
    }
    
    function validate() {
    var pw1 = document.myform.newpass1.value;
    pw1 = pw1.replace(/^\s+|\s+$/g,"");  // strip leading and trailing spaces
    var pw2 = document.myform.newpass2.value;
    pw2 = pw2.replace(/^\s+|\s+$/g,"");  // strip leading and trailing spaces
    if (pw1 != pw2) {
    alert ("The two passwords do not match!  Please try again.")
    document.myform.newpass1.value = "";
    document.myform.newpass2.value = "";
    return false;
    }
    }
    
    </script>
    Naturally you will need server-side coding to check that the old password is the same as the one recorded in your database. You will also need to validate as regards password length, acceptable characters etc.



    i raed a wlihe ago taht as lnog as the frsit and lsat lttesrs in a wrod are in the cerroct pcale msot of us wulod siltl be albe to raed bceause our barnis jsut looks at the frsit and lsat lttesrs.
    Last edited by Philip M; 06-24-2009 at 04:20 PM.


  •  

    Posting Permissions

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