1 /* This file is part of Syj, Copyright (c) 2010-2011 Arnaud Renevier,
2 and is published under the AGPL license. */
6 document.observe("dom:loaded", function() {
7 var currentmail = $("account_email").value, form = $("accountform");
11 form.observe('submit', function(evt) {
12 var control, errorElements;
14 $$('.error').invoke('remove');
16 errorElements = this.checkEmptyElements(SyjStrings.notEmptyField);
18 if (!errorElements.length) {
19 control = $("account_password");
20 if (!control.check(function() {
21 return this.value.length >= 6;
22 }, SyjStrings.passwordLenghtWarn)) {
23 errorElements.push(control);
27 if (!errorElements.length) {
28 control = $("account_password");
29 if (!control.check(function() {
30 return this.value === $("account_password_confirm").value;
31 }, SyjStrings.passwordNoMatchWarn)) {
32 errorElements.push(control);
36 if (!errorElements.length) {
37 control = $("account_email");
38 if (!control.check(function() {
39 return this.value !== currentmail || $("account_password").value !== $("account_password_current").value;
40 }, SyjStrings.nochangeWarn)) {
41 errorElements.push(control);
46 * if there are errors, cancel submission
48 if (errorElements.length) {
49 errorElements[0].highlight('#F08080').activate();