示例工程 29-registration-form

29-registration-form/demo-01-fields/index.html

html · 2.5 KB

运行:注册字段演示

点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。

<!doctype html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>注册字段演示</title>
    <style>
      body { margin: 0; padding: 32px; background: #f8fafc; color: #0f172a; font-family: system-ui, sans-serif; line-height: 1.7; }
      .box { max-width: 720px; margin-bottom: 16px; padding: 18px; border: 1px solid #e2e8f0; border-radius: 12px; background: #fff; }
      h1 { margin: 0 0 16px; font-size: 28px; }
      h2 { margin: 0 0 8px; font-size: 17px; }
      p { margin: 0 0 10px; color: #334155; }
      fieldset { margin: 0 0 14px; padding: 12px; border: 1px solid #e2e8f0; border-radius: 8px; }
      legend { padding: 0 6px; color: #475569; font-size: 14px; }
      label { display: block; margin: 6px 0 4px; font-size: 14px; }
      .inline { display: inline-flex; align-items: center; gap: 6px; margin-right: 12px; }
      input, select { width: 100%; max-width: 340px; padding: 7px 9px; border: 1px solid #cbd5e1; border-radius: 6px; font: inherit; }
      input[type="radio"], input[type="checkbox"] { width: auto; }
      .help { color: #64748b; font-size: 13px; }
      button { margin-top: 8px; padding: 7px 14px; border: 1px solid #2563eb; border-radius: 6px; background: #2563eb; color: #fff; font: inherit; }
    </style>
  </head>
  <body>
    <h1>注册字段</h1>

    <div class="box">
      <h2>账号</h2>
      <form action="welcome.html" method="post">
        <fieldset>
          <legend>账号</legend>
          <label for="name">称呼</label>
          <input id="name" name="name" type="text" autocomplete="name" required />
          <label for="email">邮箱</label>
          <input id="email" name="email" type="email" autocomplete="email" required />
          <label for="password">密码</label>
          <input id="password" name="password" type="password" minlength="8" autocomplete="new-password" required />
          <p class="help">至少 8 个字符。</p>
        </fieldset>

        <fieldset>
          <legend>角色</legend>
          <label class="inline"><input type="radio" name="role" value="developer" checked /> 开发者</label>
          <label class="inline"><input type="radio" name="role" value="designer" /> 设计师</label>
        </fieldset>

        <fieldset>
          <legend>同意</legend>
          <label class="inline"><input type="checkbox" name="terms" value="agreed" required /> 同意隐私说明</label>
        </fieldset>

        <button type="submit">创建账号</button>
      </form>
    </div>
  </body>
</html>