/* ------------------------------------------------------------------------- # # MS City JavaScript # A honlaphoz szükséges JavaScript függvények. # # Írta: Bodonyi László # E-mail cím: bodonyi.laszlo@profartis.hu # # Cégnév: Profartis Design Kft. # Honlap: http://www.profartis.com # ------------------------------------------------------------------------- */ /* * Beviteli mezőkben lévő szöveg eltűnés/megjelenítés * written by Profartis Design Kft. */ function inputToggle(event,text) { var El = Event.element(event); if(!text){ text = El.readAttribute('title'); } if(event.type == 'focus' && El.value == text){ El.value = ''; if(El.name=='s'){ El.addClassName('active'); } } if(event.type == 'blur' && El.value.blank()){ El.value = text; if(El.name=='s'){ El.removeClassName('active'); }} } /* * Űrlap ellenőrzés * written by Profartis Design Kft. */ function validateForm(f,s) { var filled = true, validEmail = true, accepted = true, focusThis = false; $(f).select('*').invoke('removeClassName','error').invoke('removeClassName','textarea_error'); $(f).select(".required").each(function(item) { if (filled == true) { // Beviteli mezők ellenőrzése if (!item.value || (item.title && item.title == item.value)) { filled = false; } // Ha e-mail címet vár a beviteli mező, akkor a helyesség ellenőrzése if (item.name.search('email') > -1) { if (validEmail) { validEmail = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/.test(item.value); } } // Ha checkbox-ot találtunk, pipálás ellenőrzése if (item.type == 'checkbox' && !item.checked) { accepted = false; } // Ha bármi hiba történt, beviteli mező megjelölése 'error' class-szal if ((!filled || !accepted || !validEmail) && !focusThis) { focusThis = item; if (item.type != 'checkbox') { //if (item.type != 'textarea') { item.addClassName('error'); //} /*else { item.parentNode.addClassName('textarea_error'); }*/ } } } }); // Ha minden rendben van... if(filled && validEmail && accepted) { // Captcha ellenőrzése var Captcha = $(f).select('#anti-spam')[0]; if( Captcha ) { new Ajax.Request('/captcha.php', { method: 'post', parameters: '&name=' + f.id.replace('form-','') + '&value=' + Captcha.value, onComplete: function(t){ if (t.responseText == 1 ){ if (typeof(s) == 'function') { s(); } else { $(f).select("input").each(function(item){ if (!item.value || (item.title && item.title == item.value)) { item.value = ''; } }); $(f).submit(); } } else { alert('Hibás ellenőrző kód!'); Captcha.focus(); } } }); return false; } else { if (typeof(s) == 'function') { s(); } else { $(f).submit(); } } return false; } // Ha hiba történt else { if(!filled && validEmail){ alert('A *-gal jelölt mezők kitöltése kötelező!'); } else if( !validEmail ){ alert('Hibás e-mail cím!'); } else { alert(focusThis.title); } focusThis.focus(); return false; } } Element.addMethods({ validateForm : function(element,submit) { return validateForm(element,submit); } });