]> git.wh0rd.org Git - tt-rss.git/commitdiff
change password form: add client-side validation
authorAndrew Dolgov <fox@bah.spb.su>
Mon, 20 Aug 2007 11:40:18 +0000 (12:40 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Mon, 20 Aug 2007 11:40:18 +0000 (12:40 +0100)
modules/pref-prefs.php
prefs.js

index 2564f30e4bab78e569eeed4020f842e446338ef6..27dfd6756043af25cb4ddd84b6a1bbc50061185b 100644 (file)
                                        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;
 
index b233d8a1ffdb779323f074365ef3c86d2ff3e5b6..2223cd9ee156ddf8d91141c1133254b0d8ab6071 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -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...");