Hello and welcome to our community! Is this your first visit?
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
    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?


  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    London, England
    Thanked 2,565 Times in 2,543 Posts
    This should give you a start:-

    <form name = "myform">
    Edit Password <input type = "checkbox" name= "chk1" id = "chk1" onclick = "showboxes()">
    <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>
    <script type = "text/javascript">
    function showboxes() {
    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;
    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 05: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