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 to the CF scene
    Join Date
    Jun 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    change password then redirect to member page

    Hello,

    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)
    }
    else
    {
    document.write(Change unsuccessful. Please try again)
    }
    </script>


    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>
    </td>

    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...

    Thanks

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

    Code:
    <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 = ''; 
            form.email.focus();
            return false;
       }     
    
        for(var i=0; i<form.elements.length; i++){
          if(form.elements[i].value == ""){
             alert('All fields must be completed!');
             form.elements[i].focus();
             return false;
          }
        }
    
        if(form.opass.value == form.npass.value){
           alert('The new password must not match the old password!');
           form.npass.value='';
           form.rnpass.value='';
           form.npass.focus();
           return false;
        }
    
        if(form.npass.value != form.rnpass.value){
           alert('New passwords do not match, try again!');
           form.npass.value='';
           form.rnpass.value='';
           form.npass.focus();
           return false;
        }  return true;
      }
     //-->
    </script>
    </head>
    
    <body>
    <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">
    </form>
    .....Willy
    Last edited by Willy Duitt; 06-23-2004 at 12:15 AM.


  •  

    Posting Permissions

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