]> dev.renevier.net Git - syj.git/blob - public/js/account.js
fixes wrong exception in release.py if no git tag is set
[syj.git] / public / js / account.js
1 /*  This file is part of Syj, Copyright (c) 2010-2011 Arnaud Renevier,
2     and is published under the AGPL license. */
3
4 document.observe("dom:loaded", function() {
5     var currentmail = $("account_email").value, form = $("accountform");
6
7     form.setfocus();
8
9     form.observe('submit', function(evt) {
10         var control, errorElements;
11
12         $$('.error').invoke('remove');
13
14         errorElements = this.checkEmptyElements(SyjStrings.notEmptyField);
15
16         if (!errorElements.length) {
17             control = $("account_password");
18             if (!control.check(function() {
19                 return this.value.length >= 6;
20             }, SyjStrings.passwordLenghtWarn)) {
21                 errorElements.push(control);
22             }
23         }
24
25         if (!errorElements.length) {
26             control = $("account_password");
27             if (!control.check(function() {
28                 return this.value === $("account_password_confirm").value;
29             }, SyjStrings.passwordNoMatchWarn)) {
30                 errorElements.push(control);
31             }
32         }
33
34         if (!errorElements.length) {
35             control = $("account_email");
36             if (!control.check(function() {
37                 return this.value !== currentmail || $("account_password").value !== $("account_password_current").value;
38             }, SyjStrings.nochangeWarn)) {
39                 errorElements.push(control);
40             }
41         }
42
43         /*
44          * if there are errors, cancel submission
45          */
46         if (errorElements.length) {
47             errorElements[0].highlight('#F08080').activate();
48             evt.stop();
49         }
50     });
51 });