// JavaScript Document function check() { var msg = ""; // firstname if ($('contactUsName').value == "" || $('contactUsName').value == "NAME") msg += "- Provide a valid name.\n"; if($('contactHome')) { if ($('contactUsLastName').value == "" ) msg += "- Provide a valid last name.\n"; } // mail if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test($('contactUsEmail').value)) msg += "- Provide a valid email address.\n"; // enquiry if ($('contactUsEnquiry').value == "" || $('contactUsEnquiry').value == "ENQUIRY") msg += "- Write your enquiry.\n"; if (msg != "") { alert("Please, fill in the following form fields:\n" + msg); return false; } else return true; } function contactar() { if (!check()) return false; Element.hide('formContacto'); Element.show('enviando'); var url = 'http://reservas.nervouswaters.com/Contactoweb/index.asp'; var params = Form.serialize('formContacto'); //'firstname=' + $('contactUsName').value+'&lastname=' + $('contactUsLastName').value + '&email=' + $('contactUsEmail').value+'&enquiry=' + $('contactUsEnquiry').value+'&country=' + $('country').value; var options = {method: 'post', parameters: params, onFailure: reportError} var ajax = new Ajax.Updater({success: 'formularioContacto'}, url, options ); } function reportError(request) { alert('Error al intentar conectar con el servidor.'); } function fill(target, value) { if (document.getElementById(target).value == '') { document.getElementById(target).value = value; return; } return; }