Age calculation and verification by calendar

I’m creating a website that renders a service to members only. Before using the service the member must complete profile information with valid information. I was able to set some patterns in the input field to ensure inserted information is valid. However the service can’t be used by minors so I would like to know how to verify age when passed through a calendar?! In other words, during the profile setup process I put a calendar with field name “date of birth”. Whenever the member select a date I need (in automation) the age of the member to be calculated and if he/she younger than a certain age (after behind the scene calculation), a pop up message or small text beside the calendar shall appear indicating age restrictions and prevent the member from carrying on profile set up process.