Block website access until users confirm an appropriate age. Redirect them if they don't meet your age requirements.
Block website access until users confirm their age to ensure compliance with age-restricted content. Redirect users who don’t meet your age requirements. This article explains how to add an age gate to your Webflow site, allowing users to confirm their age via a date selector or a simple yes/no option.
This Booster can be added directly into any Webflow projects with our official Webflow App. You can install the Webflow Boosters App and add all the structure and attributes in one click.
Copy the script source listed below, and add it to the <head>
tag of your custom code settings. If you aren't sure about custom code in Webflow, you can click here to learn more.
<!-- Flowbase Booster [Age Gate] -->
<script src="https://cdn.jsdelivr.net/npm/@flowbase-co/boosters-age-gate@1.1.0/dist/age-gate.min.js" type="text/javascript"></script>
Start by adding a ▭ div-block
to your page to cover your content and serve as the main container for the age gate. For this guide, we will name this element "Age Gate." It will be hidden for x amount of days once access is granted.
Set the element’s position to absolute
to cover your page and adjust the z-index
to ensure it sits above all other content. If you're using the app, the component will automatically include the necessary attributes and component, so you can skip these setup steps.
Add the following attributes to the 'Age Gate' element added above.
fb-age-gate
and Value: true
.fb-age-gate-type
and Value: date
. Choose between the date method or button methodfb-age-gate-minimum
and Value: 18
. This value sets the minimum age required for access.fb-age-gate-redirect
and Value: mywebsite.com
. This value sets the URL which redirects users who do not meet the age requirementsChoose between using a date input method or a button to confirm age. Each method requires different attributes, detailed below.
The date method is common as it lets users enter their birthdate, which we can check against the minimum age requirement. Since Webflow doesn’t provide date input fields by default, we’ll add extra attributes. If you prefer the button method, skip to step 5.
Inside the "Age Gate" element, add a form block with three text inputs for day, month, and year. Remove the default form submit button as it’s not needed.
Add the following attributes to the corresponding input fields
fb-age-gate-field
and Value: day
.fb-age-gate-field
and Value: month
.fb-age-gate-field
and Value: year
.For better user experience, also include these HTML attributes:
maxlength
and Value: 2
- adjust as needed, e.g., 4 for yearinputmode
and Value: numeric
After users enter their date, they need a button to confirm their details. Add a button or link-block to your site and assign the following attribute:
fb-age-gate-button
and Value: enter
.Avoid using the default form submit button to prevent form submission to Webflow. Set the default button to hidden and use your custom enter button as described.
The button method operates similarly to the date method but uses buttons for age confirmation instead of date inputs. Users can choose between confirming they are over or under the age requirement.
In the "Age Gate" element, add two buttons and style them as needed. Assign the following attributes:
fb-age-gate-button
and Value: over
.fb-age-gate-button
and Value: under
.If a user selects the button with the value "under," they will be redirected away from your website.
For a quicker setup, use our free Boosters app to add this feature without following the manual steps. Download the app from the Webflow marketplace and start using it right away at no cost.
Once you've followed the steps above and have added both the script and the attributes, you can publish your page. View your live staging domain to test the Booster in action.
Your support means the world to us! In just 10 seconds, you can make a big difference:
Thank you for being awesome! 🌟