Avatar of cbunce1121
cbunce1121

asked on 

Age Verfication Script

I need to edit my Age Verification script to be Over 18 "true" and Under 18 "false".  Any help is much appreciated.

  <script>if(document.cookie.indexOf('visited=true') === -1){jQuery.colorbox({inline:!0,href:"#verify",width:"456px",height:"450px",closeButton:!1,escKey:!1});function deny(){return!1}function allow(){var e=new Date();e.setDate(e.getDate()+30);document.cookie = "visited=true; expires="+e.toUTCString();}
    jQuery("#date>button").click(function(a){a.preventDefault();var b,c;a=jQuery("#m").val();b=jQuery("#d").val();c=jQuery("#y").val();if(!(a&&b&&c))return alert("Please provide a value for all date fields."),deny();a=moment(c+"-"+a+"-"+b);if(!a.isValid())return alert("Please provide a valid date."),deny();a.hours(0).minutes(0).seconds(0);if(0>moment().hours(0).minutes(0).seconds(0).add("y",-18).diff(a,"s"))return alert("Sorry, you are not old enough to view this site."),deny();allow();jQuery.colorbox.close()});}</script>

Here's my test site link:
http://logic-test.mybigcommerce.com/
JavaScript

Avatar of undefined
Last Comment
cbunce1121
Avatar of Gregg
Gregg
Flag of United States of America image

Hi, please wrap in CODE blocks and format spacing if needed. Difficult to read.
Avatar of cbunce1121
cbunce1121

ASKER

Not sure what you mean.  I am certainly not a coding expert.  I do minor edits for a clients website and not sure what to do based on your comment above.
Avatar of cbunce1121
cbunce1121

ASKER

 <div style="display:none">
            <div id="verify" style="font-family:Helvetica,Arial,sans-serif;text-align:center">
            <img src="/product_images/uploaded_images/logo-logic-us-desktop.png"/>
            <div style="margin:0 auto; text-align:center">
                
                <p style="margin-bottom:.5em;padding:6px;">
                <font size=4><b>Welcome to <i>LOGIC</i>.</font size></b>
                <form id="date" style="padding:6px;width:90%;margin:0 auto;text-align:center">
                    <p class="label" style="margin:0;display:inline-block">Please Certify Your Age:</p>
                       
                        <button>Under 18</button><button>Over 18</button><br>
                     <div style="margin:0 auto; text-align:span">
                
                    <p><i>Site intended for adult smokers and vapers 18 years of age or older. By entering this site, you are certifying that you are an adult smoker or vaper and are 18+ years of age. Please do not enter this site if you are not legally able to purchase tobacco products in the state where you live.</i></p>
                </form>
            </div>
        </div>
    </div>
    <script src="/template/colorbox-master/jquery.colorbox-min.js"></script>
    <script src="/template/moment.min.js"></script>
    <script>if(document.cookie.indexOf('visited=true') === -1){jQuery.colorbox({inline:!0,href:"#verify",width:"456px",height:"450px",closeButton:!1,escKey:!1});function deny(){return!1}function allow(){var e=new Date();e.setDate(e.getDate()+30);document.cookie = "visited=true; expires="+e.toUTCString();}
    jQuery("#date>button").click(function(a){a.preventDefault();var b,c;a=jQuery("#m").val();b=jQuery("#d").val();c=jQuery("#y").val();if(!(a&&b&&c))return alert("Please provide a value for all date fields."),deny();a=moment(c+"-"+a+"-"+b);if(!a.isValid())return alert("Please provide a valid date."),deny();a.hours(0).minutes(0).seconds(0);if(0>moment().hours(0).minutes(0).seconds(0).add("y",-18).diff(a,"s"))return alert("Sorry, you are not old enough to view this site."),deny();allow();jQuery.colorbox.close()});}</script>

           <script type="text/javascript" src="//assets.zendesk.com/external/zenbox/v2.5/zenbox.js"></script>
<style type="text/css" media="screen, projection">

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of cbunce1121
cbunce1121

ASKER

Thank you!  This works well.
JavaScript
JavaScript

JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.

127K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo