rejetto forum

How can users of my side can be allowed to change their passwords once created

0 Members and 1 Guest are viewing this topic.

Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
you asked for a code to clean&focus, so how can you say it does not work because the password is changed.
it has nothing to do with it. it's like complaning because it does not wash your car :)


Offline luca69

  • Occasional poster
  • *
    • Posts: 95
    • View Profile
you asked for a code to clean&focus, so how can you say it does not work because the password is changed.
it has nothing to do with it. it's like complaning because it does not wash your car :)

Maybe you got me wrong.

Let's summarize once again:

This is the current peace of code:

Code: [Select]
<form method=post action="/~userpasschange" onsubmit="return validatePassword(this);">
  <table>
  <tr><td align=left><b><font size="4"><font size="4">New Password</font></b></font></b><td><b><font size="4">: &nbsp;</font></b><span style="background-color: #000000"><input name=pass1 type=password style="font-size:10pt; font-weight:bold; border:1px solid #88f" size="20" ></span>
  <tr><td align=left><b><font size="4"><font size="4">Type Password again</font></b></font></b><td><b><font size="4">: &nbsp;</font></b><span style="background-color: #000000"><input name=pass2 type=password style="font-size:10pt; font-weight:bold; border:1px solid #88f" size="20" ></span>
  <tr><td align=left><font size="4">Click <a href="/">here</a> to return to HOME.</font><td align=center><input type=submit value="Change">
  </tr></table>
</form>

It uses a java script called "validatePassword" to check that pass1 and pass2 match:

Code: [Select]
<script type="text/javascript">
function validatePassword(form){
if (form.pass1.value != form.pass2.value){
alert("Password mismatch: please enter again.");
return false;
  }
 return true;
}
</script>

It works fine. If pass1 != pass2 then there is a message box and the user has to enter the new password again.

But first the user must "clean" the fields pass1 and pass2.

Here it comes your hint and I modified the java code:

Code: [Select]
<script type="text/javascript">
function validatePassword(form){
if (form.pass1.value != form.pass2.value){
alert("Password mismatch: please enter again.");
return false;
    from.pass1.value = "";
    from.pass2.value = "";
  form.pass1.focus();
  }
 return true;
}
</script>

Now the message box pops up but the password is ALWAYS changed, even if the pass1 !=  pass2 !

Is it clear now?

PS: Sorry for such a silly questions, but I'm not a java expert :(
Life is what happens to you while you are busy making other plans


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile

Offline luca69

  • Occasional poster
  • *
    • Posts: 95
    • View Profile
try fixing "from." in "form."
and move my code before the alert()

DAMMIT!!! YOU ARE RIGHT !!!

...I'm getting old  :(

PS: It is working also without moving the code before the alert()  ;)
« Last Edit: April 24, 2009, 07:48:06 AM by luca69 »
Life is what happens to you while you are busy making other plans