X-Git-Url: https://dev.renevier.net/?a=blobdiff_plain;f=public%2Fjs%2Fcontact.js;h=eb8cf921b25d5c103066958487bda4f2db442243;hb=facf74e6972eafb727833b85b38b061215dea833;hp=1213e6eb5e9c7ef9f04eb11db339a8a5eb3aef39;hpb=9efd079d59d269811abc4c551b2f39ab2e6a05fb;p=syj.git diff --git a/public/js/contact.js b/public/js/contact.js index 1213e6e..eb8cf92 100644 --- a/public/js/contact.js +++ b/public/js/contact.js @@ -1,21 +1,18 @@ -/* 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 form = $("contactform"); - form.focus(); + form.setfocus(); form.observe('submit', function(evt) { var control, errorElements; $$('.error').invoke('remove'); - errorElements = $$('input:not([type="submit"]),textarea').findAll( - function(elt) { - return (!elt.check(function() { - return !this.value.strip().empty(); - }, SyjStrings.notEmptyField)); - }); + errorElements = this.checkEmptyElements(SyjStrings.notEmptyField); if (!errorElements.length) { control = $("contact_email"); @@ -30,8 +27,7 @@ document.observe("dom:loaded", function() { * if there are errors, cancel submission */ if (errorElements.length) { - errorElements[0].highlight('#F08080').focus(); - errorElements[0].select(); + errorElements[0].highlight('#F08080').activate(); evt.stop(); } });