LEYUN · SITE SPEC & COMPONENT LIBRARY独立站技术规范手册

Age Verification Dialog Component Rules

Section:COMPLIANCE BANNER SPEC · Reviewed:2026-11-20 · Template asset

Key takeawayThis section defines the structure template, field dictionary, integration points and compliance boundaries for 「Age Verification Dialog Component Rules」 in COMPLIANCE BANNER SPEC. Templates are for reference only; verify local regulations and platform rules before launch.

Industries and use cases

  • Restricted products such as alcohol, nicotine or gambling-related items
  • Sellers facing age limits on specific categories in various countries
  • Scenarios requiring age confirmation before entering the site or before purchase
  • Sites selling regulated goods such as knives or alcohol-containing products
Template / code snippethtml
<!-- 年龄确认:进入站点时拦截 -->
<div class="age-gate" id="ageGate" role="dialog"
     aria-modal="true" aria-labelledby="ageTitle" hidden>
  <div class="age-in">
    <h2 id="ageTitle">Age verification required</h2>
    <p>
      The products sold on this site are restricted to
      customers aged ${minAge} or above.
      Please confirm your age to continue.
    </p>
    <div class="age-actions">
      <button type="button" class="age-btn age-yes" data-age="yes">
        I am ${minAge} or older</button>
      <button type="button" class="age-btn age-no" data-age="no">
        I am not ${minAge} or older</button>
    </div>
    <p class="age-note">
      By entering this site you accept our terms of sale
      and confirm that you are of legal age in your country of residence.
    </p>
  </div>
</div>

<!-- 拒绝后的处理:不刷新循环,而是给出明确出口 -->
<script>
(function () {
  var gate = document.getElementById('ageGate');
  var KEY = 'age_ok_v1';
  var ok = false;
  try { ok = localStorage.getItem(KEY) === '1'; } catch (e) {}
  if (!ok) {
    document.body.classList.add('age-locked');
    gate.hidden = false;
  }
  gate.querySelector('[data-age="yes"]').addEventListener('click', function () {
    try { localStorage.setItem(KEY, '1'); } catch (e) {}
    document.body.classList.remove('age-locked');
    gate.hidden = true;
  });
  gate.querySelector('[data-age="no"]').addEventListener('click', function () {
    gate.querySelector('.age-in').innerHTML =
      '<h2>Sorry</h2><p>You must be ' + ${minAge} +
      ' or older to enter this site.</p>' +
      '<p><a href="/contact/">Contact us if you have questions</a></p>';
  });
})();
</script>
Fields and parameters
Field / parameterTypeDescription and values
Minimum ageIntegerSet by the regulations of the target market
Confirmation buttonsElementTwo explicit options, phrased as first-person statements
Handling a refusalTextProvide an exit, never loop the dialog
State recordTextlocalStorage to avoid repeat prompts
Page lockCSS classBlocks interaction until confirmed
Terms acknowledgementParagraphEntering the site is treated as accepting the terms

SEO and structured-data notes

SEO and structured-data checkpoints
The confirmation must not be bypassablePage interaction should be locked until confirmed; showing a dialog while the page still works undermines the point of age verification
Set the threshold per marketAge requirements for a given category differ between countries; one number cannot be applied everywhere
A refusal must not loop the dialogRepeatedly reopening the dialog traps the user and is a common usability defect
Phrase buttons in the first person"I am 18 or older" is clearer than "Yes" and more readily accepted as valid confirmation
Store the state locallyThis avoids asking on every visit
Combine terms and age confirmationPlace acceptance of the terms of sale alongside the age confirmation

Compliance risk notes

  • The age threshold must not be set below the regulatory requirement
  • Vague wording must not be used to bypass the age requirement
  • Identity documents and other unnecessary proof must not be collected
  • Age verification does not replace compliance checks at payment and logistics
  • For alcohol products, age verification and delivery licensing are separate requirements

Do not reuse this template verbatim in regulated contexts; verify local regulations and platform rules before going live.

Modification example

<!-- Modification example: from "ask on every page" to "ask once, with an exit" -->
<!-- Original: the dialog loops after refusal and the user cannot leave -->
<script>
if (!sessionStorage.age_ok) { showGate(); }
function onNo() { showGate(); }   <!-- wrong: cannot be closed after refusal -->
</script>

<!-- Modified: record the state and provide an exit on refusal -->
<script>
var KEY = 'age_ok_v1';
var ok = false;
try { ok = localStorage.getItem(KEY) === '1'; } catch (e) {}
if (!ok) {
  document.body.classList.add('age-locked');
  document.getElementById('ageGate').hidden = false;
}
document.querySelector('[data-age="yes"]').addEventListener('click', function () {
  try { localStorage.setItem(KEY, '1'); } catch (e) {}
  document.body.classList.remove('age-locked');
  document.getElementById('ageGate').hidden = true;
});
document.querySelector('[data-age="no"]').addEventListener('click', function () {
  document.querySelector('.age-in').innerHTML =
    '<h2>Sorry</h2><p>You must be ' + ${minAge} +
    ' or older to enter this site.</p>' +
    '<p><a href="/contact/">Contact us if you have questions</a></p>';
});
</script>

<!-- Three key changes:
     1. localStorage instead of sessionStorage — remembered across sessions,
        so a new session does not trigger the question again
     2. after refusal the gate is replaced by an explanation and a contact route,
        removing the "cannot be closed" loop entirely
     3. the age-locked class makes the page non-interactive,
        so the page is locked until confirmation
     Whether age verification holds up depends on whether confirmation is real
     and whether refusal is equally reachable — the latter is what many implementations miss. -->

FAQ

Is the age dialog the same as payment verification?
No. Age verification confirms age; payment and logistics carry their own compliance requirements.
Can a user still contact support after refusal?
Yes, and they should be able to. Some buyers click the wrong button and need a recovery route.
Should the age gate block search engines?
Do not use noindex. The page remains crawlable; the gate only adds an interaction step for visitors.
Must the dialog appear every time?
No. Storing the confirmation once is enough; frequent prompts only degrade the experience.
Version notes2026-11-20: first release, compiled from official Google documentation and public technical sources; updated as engine rules change. Engine behaviour details follow the latest official Google documentation.

Note: this page is a summary of publicly documented search-engine rules and is for self-check reference only. Engine behaviour is subject to the latest official Google documentation; verify against your own Search Console data.