X-Git-Url: https://dev.renevier.net/?a=blobdiff_plain;f=public%2Fjs%2Faccount.js;h=c54353268ea3d410d7f38a739869fdba90d9f0fe;hb=c06c7fd6e6f26d31abb8d7c9a9f9e3f2d5b27d5c;hp=f6e204a29339816e71bc80565bcd17cea1052f51;hpb=190fd621df4920c56a422c03663874cddaa67d64;p=syj.git diff --git a/public/js/account.js b/public/js/account.js index f6e204a..c543532 100644 --- a/public/js/account.js +++ b/public/js/account.js @@ -1,23 +1,19 @@ -/* This file is part of Syj, Copyright (c) 2010 Arnaud Renevier, +/* This file is part of Syj, Copyright (c) 2010-2011 Arnaud Renevier, and is published under the AGPL license. */ +"use strict"; + document.observe("dom:loaded", function() { var currentmail = $("account_email").value, form = $("accountform"); - form.focus(); + form.setfocus(); form.observe('submit', function(evt) { var control, errorElements; $$('.error').invoke('remove'); - errorElements = $$('#account_email, #account_password').findAll( - function(elt) { - return (!elt.check(function() { - return !this.value.strip().empty(); - }, SyjStrings.notEmptyField)); - }); - + errorElements = this.checkEmptyElements(SyjStrings.notEmptyField); if (!errorElements.length) { control = $("account_password"); @@ -30,7 +26,7 @@ document.observe("dom:loaded", function() { if (!errorElements.length) { control = $("account_password"); - if (control.check(function() { + if (!control.check(function() { return this.value === $("account_password_confirm").value; }, SyjStrings.passwordNoMatchWarn)) { errorElements.push(control); @@ -50,8 +46,7 @@ document.observe("dom:loaded", function() { * if there are errors, cancel submission */ if (errorElements.length) { - errorElements[0].focus(); - errorElements[0].select(); + errorElements[0].highlight('#F08080').activate(); evt.stop(); } });