newsletter

Nyhetsbrev icon Uutiskirje
Eksklusiivisia tarjouksia NettiKasinoVertailu.infoista suoraan sähköpostiisi.

 

Kiitos rekisteröitymisestä!

function watch_email() {

$( "#newsletter_email" ).bind("propertychange change click keyup input paste",function() {

errorDisplay.innerHTML="";

if( validateEmail( $( "#newsletter_email" ).val() ) ) {

$( "#newsletter_submit" ).show();

$("#registerNewsletterText").hide();

} else {

$( "#newsletter_submit" ).hide();

$("#registerNewsletterText").show();

}

});

}

function validateEmail(email) {

var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;

return re.test(email);

}

function registerNewsletter(obj) {

var errorDisplay = document.getElementById("errorDisplay");

errorDisplay.innerHTML="";

console.log($(obj).serialize());

$.ajax({

type: 'post',

url: "/newsletter/register/",

dataType: "json",

context: obj,

data:$(obj).serialize(),

success: function (data) {

if(data.error !== undefined){

switch(data.error){

case "emptyEmail":

errorDisplay.innerHTML="Unohdit kirjoittaa sähköpostiosoitteesi";

break;

case "invalidEmail":

errorDisplay.innerHTML="Sähköpostiosoite on virheellinen";

break;

case "takenEmail":

errorDisplay.innerHTML="Sähköpostiosoite on rekisteröity jo kertaalleen";

break;

default :

errorDisplay.innerHTML="Tuntematon virhe.";

break;

}

} else {

$("#registerNewsletterForm").slideUp();

$("#registerNewsletterFormSuccess").slideDown();

createCookie('newsletter',true,365);

}

}

,error: function (data) {

errorDisplay.innerHTML="Tuntematon virhe. Tarkasta nettiyhteytesi?";

}

});

}

document.addEventListener("DOMContentLoaded", function(event) {

if( readCookie('newsletter') === null ) {

document.getElementById("registerNewsletter").style.display = 'block';

}

$("#registerNewsletterForm").submit( function( event ) {

registerNewsletter($("#registerNewsletterForm"));

event.preventDefault($(this));

});

});

function createCookie(name,value,days) {

if (days) {

var date = new Date();

date.setTime(date.getTime()+(days*24*60*60*1000));

var expires = "; expires="+date.toGMTString();

}

else var expires = "";

document.cookie = name+"="+value+expires+"; path=/";

}

function readCookie(name) {

var nameEQ = name + "=";

var ca = document.cookie.split(';');

for(var i=0;i

var c = ca[i];

while (c.charAt(0)==' ') c = c.substring(1,c.length);

if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);

}

return null;

}

function eraseCookie(name) {

createCookie(name,"",-1);

}


NettiKasinoVertailu.info