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