Check Date of Birth


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function checkDOB() {
  2. var date = new Date();
  3. var full18 = new Date(date.getFullYear() - 18, date.getMonth(), date.getDate());
  4. var dob = new Date(form['yyyy'].value, form['mm'].value, form['dd'].value);
  5.  
  6. if (full18 < dob) {
  7. alert('You must be 18 years or older to be eligible for this offer. Please enter your correct Date of Birth or click Pass to see the next offer.');
  8. return false;
  9. }
  10. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.