$(document).ready(function() { if (window.location.toString().indexOf('/contatti.asp') == -1){ var ordinaShown = false; $('a[@rel*=lightbox-gallery]').lightBox(); $('#go-ordina').click(function() { if (!ordinaShown){ ordinaShown = true; strHtml = $('#ordina').html(); $('#prezzo').after('
'); $('#ordina2').append(strHtml).hide().slideDown('slow'); } return false; }); } else { var initCptValue = $('#cpt').val(); var initEmailVal = $('#email').val(); $('#cpt').focus(function() { if ($(this).val() == initCptValue) $(this).val(''); }); $('#cpt').blur(function() { if ($(this).val() == '') $(this).val(initCptValue); }); $('#email').focus(function() { if ($(this).val() == initEmailVal) $(this).val(''); }); $('#email').blur(function() { if ($(this).val() == '') $(this).val(initEmailVal); }); function validate(email) { var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; if(reg.test(email) == false) return false; else return true; }; $('#formContatti').submit(function() { var isValid = true; // check name if ($('#name').val().length < 2){ if ($('#name').parent().next().attr('class') != 'alert') $('#name').parent().after('
  • Inserire un nome valido
  • '); $('#name').parent().next().hide().slideDown(); isValid = false; } else if ($('#name').parent().next().attr('class') == 'alert') $('#name').parent().next().hide(); // check email if (!validate($('#email').val())){ if ($('#email').parent().next().attr('class') != 'alert') $('#email').parent().after('
  • Inserire un email valida
  • ') $('#email').parent().next().hide().slideDown(); isValid = false; } else if ($('#email').parent().next().attr('class') == 'alert') $('#email').parent().next().hide(); // check message if ($('#txt').val().length < 5){ if ($('#txt').parent().next().attr('class') != 'alert') $('#txt').parent().after('
  • Inserire un messaggio valido
  • ') $('#txt').parent().next().hide().slideDown(); isValid = false; } else if ($('#txt').parent().next().attr('class') == 'alert') $('#txt').parent().next().hide(); // check antispam if ($('#cpt').val().length != 3){ if ($('#cpt').parent().next().attr('class') != 'alert') $('#cpt').parent().after('
  • Per favore copia il codice antispam.
  • ') $('#cpt').parent().next().hide().slideDown(); isValid = false; } else if ($('#cpt').parent().next().attr('class') == 'alert') $('#cpt').parent().next().hide(); if (!isValid) return false; else $('#submit').val('Sto inviando...').attr({disabled: 'disabled'}); }); }; });