How to Create an Age Gate Popup [Advanced PRO]

				
					
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

Global Colors and Fonts

Elementor Theme Builder Overview

business card

Create a Virtual Digital Business Card

The Future
of Web Creation. Straight to
Your Inbox.

What interests you?

Great!

Awsome content is on the way.

More Resources

Birthday Sale: Up to 50% Off
Birthday Sale: Last 24 hours!
Birthday Sale: Last 24 hours:
DAYS
HR
MINS
SEC
Wait! You get 30-Day Money-back Guarantee

You have nothing to lose – but the discount

days
hours
minutes
seconds