View Full Version : Slidedown box for change password

06-24-2009, 04:20 PM
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?


Philip M
06-24-2009, 04:55 PM
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.