]> dev.renevier.net Git - syj.git/blob - public/js/contact.js
update copyright headers
[syj.git] / public / js / contact.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 form = $("contactform");
6     form.setfocus();
7
8     form.observe('submit', function(evt) {
9         var control, errorElements;
10
11         $$('.error').invoke('remove');
12
13         errorElements = this.checkEmptyElements(SyjStrings.notEmptyField);
14
15         if (!errorElements.length) {
16             control = $("contact_email");
17             if (!control.check(function() {
18                 return this.value.match(/^[A-Z0-9._\-]+@[A-Z0-9][A-Z0-9.\-]{0,61}[A-Z0-9]\.[A-Z.]{2,6}$/i);
19               }, SyjStrings.invalidMail)) {
20                 errorElements.push($("contact_email"));
21             }
22         }
23
24         /*
25          * if there are errors, cancel submission
26          */
27         if (errorElements.length) {
28             errorElements[0].highlight('#F08080').activate();
29             evt.stop();
30         }
31     });
32
33 });