1 /* This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
2 and is published under the AGPL license. */
4 document.observe("dom:loaded", function() {
5 var form = $("contactform");
8 form.observe('submit', function(evt) {
9 var control, errorElements;
11 $$('.error').invoke('remove');
13 errorElements = $$('input:not([type="submit"]),textarea').findAll(
15 return (!elt.check(function() {
16 return !this.value.strip().empty();
17 }, SyjStrings.notEmptyField));
20 if (!errorElements.length) {
21 control = $("contact_email");
22 if (!control.check(function() {
23 return this.value.match(/^[A-Z0-9._\-]+@[A-Z0-9][A-Z0-9.\-]{0,61}[A-Z0-9]\.[A-Z.]{2,6}$/i);
24 }, SyjStrings.invalidMail)) {
25 errorElements.push($("contact_email"));
30 * if there are errors, cancel submission
32 if (errorElements.length) {
33 errorElements[0].focus();
34 errorElements[0].select();