View Full Version : change password then redirect to member page

creepin' up
06-22-2004, 09:21 PM

I am trying to write a script to change passwords and take the user back to the member area once it is confirmed.

I haven't been to school for any of this, so, I'm trying to learn thru books and forums.

Here is what I have so far:

<script language="javascript">
function change_pass()
var name=opass
var name=npass
var name=rnpass

if (opass == 1 && npass == rnpass)
documnet.write(Change successful)
document.write(Change unsuccessful. Please try again)

Here is the text boxes:

<td width="579" height="227" bgcolor="#C0C0C0">
<p align="center"><font color="#800080"><b>Email address<br>
<input type="text" name="email" size="20" maxlength="100"></b></font></p>

<p align="center"><font color="#800080"><b>Old password<br>
<input type="text" name="opass" size="20" maxlength="16"></b></font></p>

<p align="center"><font color="#800080"><b>New password <br>
<input type="text" name="npass" size="20" maxlength="16"></b></font></p>

<p align="center"><b><font color="#800080">Re-enter new password</font></b><br>
<input type="text" name="rnpass" size="20" maxlength="16"></p>

Any help you can give will be appreciated. I have read and re-read the books, tutorials, and forum posts from other people. Just when I think I'm about to understand it all... well...


Willy Duitt
06-23-2004, 12:07 AM
Without knowing how your form is submitted I can not help you with redirecting back to your main area, but that should be handled on the server after the form values are once again evaluated since javascript can be turned off and therefore any clientside validation will fail.

Anyway, this should help.

<script type="text/javascript">
function validate(form){
var goodEmail = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(form.email.value);
if(form.email.value!= "" && !goodEmail){
alert('Please enter a valid email address.');
form.email.value = '';
return false;

for(var i=0; i<form.elements.length; i++){
if(form.elements[i].value == ""){
alert('All fields must be completed!');
return false;

if(form.opass.value == form.npass.value){
alert('The new password must not match the old password!');
return false;

if(form.npass.value != form.rnpass.value){
alert('New passwords do not match, try again!');
return false;
} return true;

<form method="post" action="" onsubmit="return validate(this)">
Email address: <input type="text" name="email"><br>
Old password: <input type="password" name="opass"><br>
New password: <input type="password" name="npass"><br>
Re-enter new password: <input type="password" name="rnpass"><br>
<input type="submit" value="Submit">