change password form: add client-side validation

This commit is contained in:
Andrew Dolgov 2007-08-20 12:40:18 +01:00
parent b652c1b7c4
commit ae661a8cfc
2 changed files with 32 additions and 1 deletions

View File

@ -316,7 +316,8 @@
owner_uid = ".$_SESSION["uid"]."
ORDER BY section_id,short_desc");
print "<form action=\"backend.php\" method=\"POST\" id=\"pref_prefs_form\">";
print "<form onsubmit='return false' action=\"backend.php\"
method=\"POST\" id=\"pref_prefs_form\">";
$lnum = 0;

View File

@ -1684,6 +1684,36 @@ function changeUserPassword() {
return false;
}
var f = document.forms["change_pass_form"];
if (f) {
if (f.OLD_PASSWORD.value == "") {
new Effect.Highlight(f.OLD_PASSWORD);
notify_error("Old password cannot be blank.");
return false;
}
if (f.NEW_PASSWORD.value == "") {
new Effect.Highlight(f.NEW_PASSWORD);
notify_error("New password cannot be blank.");
return false;
}
if (f.CONFIRM_PASSWORD.value == "") {
new Effect.Highlight(f.CONFIRM_PASSWORD);
notify_error("Entered passwords do not match.");
return false;
}
if (f.CONFIRM_PASSWORD.value != f.NEW_PASSWORD.value) {
new Effect.Highlight(f.CONFIRM_PASSWORD);
new Effect.Highlight(f.NEW_PASSWORD);
notify_error("Entered passwords do not match.");
return false;
}
}
var query = Form.serialize("change_pass_form");
notify_progress("Trying to change password...");