YaWK
24.1
Yet another WebKit
|
Go to the source code of this file.
Functions | |
document | ready (function(){ initTimer();function initTimer(){ var myTimer=0;$("#form").on('keydown', function() { if(myTimer) { clearTimeout(myTimer);} myTimer=setTimeout(function() { checkForm();}, 300);});} function checkForm(){ $('#form').validate({ errorPlacement:function(error, element) { error.insertBefore(element);}, rules:{ name:{ required:true, minlength:4, maxlength:48 }, email:{ required:true, email:true, maxlength:128 } } });} $('#submit').click(function(){ var email=$('#email').val();var name=$('#name').val();if(!email.trim()) { $("#form").effect("shake", {times:3}, 820);return false;} else { checkForm();} $.ajax({ url:'system/widgets/newsletter/js/nl.php', type:'post', crossOrigin:true, data:'name='+name+'&email='+email, success:function(data){ if(! data){ alert('Something went wrong!');return false;} else { $("#formWrapper").hide();if(name) { user=name;} else { user=email;} $("#thankYouMessage").append('< h2 >Thank you '+user+'< small >for subscribing to the newsletter!</small ></h2 >');$(data).hide().prependTo("#thankYouMessage").fadeIn(820);} } });});}) |
document ready | ( | function(){ initTimer();function initTimer(){ var myTimer=0;$("#form").on('keydown', function() { if(myTimer) { clearTimeout(myTimer);} myTimer=setTimeout(function() { checkForm();}, 300);});} function checkForm(){ $('#form').validate({ errorPlacement:function(error, element) { error.insertBefore(element);}, rules:{ name:{ required:true, minlength:4, maxlength:48 }, email:{ required:true, email:true, maxlength:128 } } });} $('#submit').click(function(){ var email=$('#email').val();var name=$('#name').val();if(!email.trim()) { $("#form").effect("shake", {times:3}, 820);return false;} else { checkForm();} $.ajax({ url:'system/widgets/newsletter/js/nl.php', type:'post', crossOrigin:true, data:'name='+name+'&email='+email, success:function(data){ if(! data){ alert('Something went wrong!');return false;} else { $("#formWrapper").hide();if(name) { user=name;} else { user=email;} $("#thankYouMessage").append('< h2 >Thank you '+user+'< small >for subscribing to the newsletter!</small ></h2 >');$(data).hide().prependTo("#thankYouMessage").fadeIn(820);} } });});} | ) |