function esito(id){ switch (id) { case 1: alert('Grazie per averci contattato'); break; case 2: alert('Grazie per aver scaricato il nostro pdf'); break; case 3: alert('errore, campo obbligatorio mancante'); break; case 4: alert('Grazie per esserti iscritto alla nostra newsletter'); break; default: alert('errore, riprovare'); } } function hideMailMsg(id){ $('.showMailMsg').hide(); } function showMailMsg(str, id, box){ //alert('#'+id+'.'+box+' .errore'); $('#'+id+' .'+box+' .errore').html(str); } function checkNewsletter(f, id, page) { //var f = document.forms["myMagazine"]; var __filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/; var __data = /^(((0[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/((19|[2-9]\d)\d{2}))|((0[1-9]|[12]\d|30)\/(0[13456789]|1[012])\/((19|[2-9]\d)\d{2}))|((0[1-9]|1\d|2[0-8])\/02\/((19|[2-9]\d)\d{2}))|(29\/02\/((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$/; $check=true; $('.errore').html(''); if( f.nick.value == '' ) { showMailMsg('(campo obbligatorio)', id, 'nome'); //f.nome.focus(); $check=false; } if( f.email.value == '' ) { showMailMsg('(campo obbligatorio)', id, 'email'); //f.email.focus(); $check=false; } if (!__filter.test( f.email.value )) { showMailMsg('(formato email non valido)', id, 'email'); //f.email.focus(); $check=false; } //alert (f.consenso.checked); if (!(f.consenso.checked)){ showMailMsg('(è necessario autorizzare il trattamento dei dati personali)
', id, 'consenso'); //f.consenso.focus(); $check=false; } if ($check){ $.post(page, { nick: f.nick.value, email: f.email.value }, function(data){ //alert (data); if(data) $('#'+id+' .esito').html('Grazie per esserti iscritto alla nostra newsletter.'); else $('#'+id+' .esito').html('Si e\' verificato un errore durante l\'iscrizione riprovare.'); $('#'+id+' .esito').show(); } ); return false; } else return false; }