<form action="/register" method="POST" class="f1">
  <h1>Register</h1>

  <div class="form-group">
    <label for="handle">handle *</label>
    <input class="<%= ctx.errors.form_input_class "handle" %>" type="text" name="handle" value="<%= ctx.old["handle"] %>" />
    <%= ctx.errors.form_group_p "handle" -%>
  </div>
  <div class="form-group">
    <label for="password">password *</label>
    <input class="<%= ctx.errors.form_input_class "password" %>" type="password" name="password" autocomplete="new-password" />
    <%= ctx.errors.form_group_p "password" -%>
  </div>
  <div class="form-group">
    <label for="password2">confirm password *</label>
    <input class="<%= ctx.errors.form_input_class "password2" %>" type="password" name="password2" autocomplete="new-password" />
    <%= ctx.errors.form_group_p "password2" -%>
  </div>
  <div class="form-group">
    <label>email <span class="small text-muted">optional</span></label>
    <input class="<%= ctx.errors.form_input_class "email" %>" type="text" name="email" value="<%= ctx.old["email"] %>" />
    <%= ctx.errors.form_group_p "email" -%>
    <p class="text-sm">used for password recovery and optional notifications</p>
  </div>
  <%- if invitecode_required || invitecode.presence || ctx.old["invitecode"].presence -%>
  <div class="form-group">
    <label for="invitecode">invite code <% if invitecode_required %>*<% end %></label>
    <input class="form-control <%= ctx.errors.form_input_class "invitecode" %>" type="text" name="invitecode" value="<%= (ctx.old["invitecode"].presence || invitecode) %>" />
    <%= ctx.errors.form_group_p "invitecode" -%>
    <%- if invitecode_required && !ctx.errors.form_group_p("invitecode").presence -%>
      <p>invite code required</p>
    <%- end -%>
  </div>
  <%- end -%>
  <div class="form-group">
    <button type="submit" class="btn btn-primary">Submit</button>
    <p class="text-sm text-right">
      <a class="opacity-75" href="<%= login_uri %>">already have an account? login</a>
    </p>
  </div>
</form>
