Note that there are some explanatory texts on larger screens.

plurals
  1. POAge Verification - Close Dialog Window
    primarykey
    data
    text
    <p>Using Nation Builder as a platform for a client's site and need to create an age gate. I would have the age verification on a separate page but apparently it won't work with this platform, so I'm using a Jquery dialog to show on top of the home page. The code I got to verify age works, but need to tweak it in order to close the widget UI instead of a url redirect. </p> <p>I'm no programming expert so any help and dumming it down would be appreciated. Here's a link. <a href="http://patricialourenco.com/test.html" rel="nofollow">http://patricialourenco.com/test.html</a> Cheers!</p> <pre><code>var ageCheck = { //Set the minimum age and where to redirect to minimumAge : 13, userIsOldEnoughPage : "http://www.bullyproject.com", userNotOldEnoughPage : " http://www.pacerkidsagainstbullying.org/#/home", //Leave this stuff alone please :) start: function() { this.setUsersBirthday(); if (this.userIsOverMinimumAge()) { this.setCookie("usersBirthday",this.usersBirthday,30); window.location = this.userIsOldEnoughPage; } else{ this.notMinimumAge(); }; }, usersBirthday : new Date(), setTheMonth : function() { var selectedMonth = document.getElementById("month").value; if (selectedMonth === "1") { this.setDaysForMonth(29); } else if (selectedMonth === "3" || selectedMonth === "5" || selectedMonth === "8" || selectedMonth === "10") { this.setDaysForMonth(30); } else { this.setDaysForMonth(31); }; }, setDaysForMonth : function(x) { var daySelectTag = document.getElementsByName('day')[0]; daySelectTag.options.length = 0; for(var i=1; i &lt;= x; i++) { daySelectTag.options.add(new Option(i, i)); } }, setUsersBirthday: function() { var usersMonth = document.getElementById("month").value; var usersDay = document.getElementById("day").value; var usersYear = document.getElementById("year").value; this.usersBirthday.setMonth(usersMonth); this.usersBirthday.setDate(usersDay); this.usersBirthday.setFullYear(usersYear); }, setMinimumAge: function() { var today = new Date(); today.setFullYear(today.getFullYear() - this.minimumAge); return today; }, notMinimumAge : function() { window.location = this.userNotOldEnoughPage }, userIsOverMinimumAge: function () { if (this.usersBirthday &lt; this.setMinimumAge()) { return true; } }, setCookie: function (c_name,value,exMinutes) { var exdate=new Date(); exdate.setMinutes(exdate.getMinutes() + exMinutes); var c_value=escape(value) + ((exMinutes==null) ? "" : "; expires="+exdate.toUTCString()); document.cookie=c_name + "=" + c_value; }, getCookie: function (c_name) { var i,x,y,ARRcookies=document.cookie.split(";"); for (i=0;i&lt;ARRcookies.length;i++) { x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("=")); x=x.replace(/^\s+|\s+$/g,""); if (x==c_name) { return unescape(x); } } }, checkCookie: function () { var usersBirthday=this.getCookie("usersBirthday"); if (usersBirthday==null || usersBirthday=="") { window.location = "ageCheckTester.html"; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload