]> dev.renevier.net Git - syj.git/blob - public/js/newpwd.js
977e9959a7418aa7dc463543f654332d54b32b02
[syj.git] / public / js / newpwd.js
1 /*  This file is part of Syj, Copyright (c) 2010-2011 Arnaud Renevier,
2     and is published under the AGPL license. */
3 function insertErrorBefore(elt, messageError) {
4     var message = new Element("div", {className: 'error'}).update(messageError);
5     elt.insert({before: message});
6 }
7
8 document.observe("dom:loaded", function() {
9     var errors, tofocus;
10
11     errors = $$('.error');
12     tofocus = null;
13     if (errors.length) {
14         tofocus = $('newpwd_email');
15     } else {
16         tofocus = $$('form input:not([readonly],[disabled])')[0];
17     }
18     if (tofocus) {
19         tofocus.activate();
20     }
21
22     $("newpwdform").observe('submit', function(evt) {
23         $$('.error').invoke('remove');
24         if ($('newpwd_email').value.strip().empty()) {
25             insertErrorBefore($('newpwdform').select('table')[0], SyjStrings.notEmptyField);
26             $('newpwd_email').highlight('#F08080').activate();
27             evt.stop();
28         }
29     });
30
31 });