How to Create an Age Gate Popup [Advanced PRO]

In this tutorial we learn how to create an Age Gate Popup. We’ll explore three different methods to achieve this. The first will make use of the buttons widget. In the second method we’ll use the acceptance field on a form. And in the third and final solution, we’ll utilize some custom Javascript to allow the user to enter their date of birth.

The tutorial will cover:
✔︎ How to create a popup
✔︎ How to create an age gate using buttons
✔︎ How to create an age gate using the acceptance field on a form
✔︎ How to create an age gate using the date field on a form
✔︎ And much more!

Custom Javascript:

document.getElementById("dateofbirthsubmit").addEventListener('click',function ()
{
var dateString = document.getElementById('form-field-dateofbirth').value;
if(dateString !=='')
{
var today = new Date();
var birthDate = new Date(dateString);
var age = today.getFullYear() - birthDate.getFullYear();

if(age < 18 || age > Infinity)
{
elementorProFrontend.modules.popup.showPopup( {id:50}, event);
event.preventDefault();
}
}
else
{
alert("You must provide your date of birth!");
}
} );

Related Topics

Share

Was This Helpful?

Thanks for your feedback!

Recommended Videos

The Future
of Web Creation. Straight to
Your Inbox.

What interests you?

Great!

Awsome content is on the way.

More Resources