1 /* This file is part of Syj, Copyright (c) 2010-2011 Arnaud Renevier,
2 and is published under the AGPL license. */
4 document.observe("dom:loaded", function() {
5 var currentmail = $("account_email").value, form = $("accountform");
9 form.observe('submit', function(evt) {
10 var control, errorElements;
12 $$('.error').invoke('remove');
14 errorElements = this.checkEmptyElements(SyjStrings.notEmptyField);
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);
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);
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);
44 * if there are errors, cancel submission
46 if (errorElements.length) {
47 errorElements[0].highlight('#F08080').activate();