agentleFS
pabloirracionalpabloirracional/claude-skills/skills/handling-web-forms/SKILL.md

handling-web-forms

Skill0 starsChanged 4 months agoMITView on GitHub

Builds web forms with a tested validation function, honeypot spam filtering, and explicit submit/loading/error states - ready-to-adapt HTML/JS template included. Use whenever the user wants a contact form, signup form, lead capture form, or any form needing validation and submission handling.

The file

Files
SKILL.md

Handling web forms

Builds a form with validation logic that's testable independently of the DOM, a honeypot spam filter, and all three submission states handled explicitly.

Workflow

  1. Start from scripts/form-template.html rather than writing from scratch - it already has the pattern below implemented and tested. Adapt the fields, not the structure.
  2. Keep validation logic as a pure function, separate from DOM code (see validateForm() in the template) - this is what makes it possible to unit-test the rules without a browser, and to reuse the same rules server-side.
  3. Validate on blur, not only on submit - catches errors while the user is still in the field, before they've moved on and forgotten the context.
  4. Honeypot for spam: an invisible field (tabindex="-1", positioned off-screen, autocomplete="off") that real users never fill - if it has a value on submit, silently drop instead of showing an error (don't tip off bots that they were caught).
  5. Three states, always: idle → submitting (disable the button, show a status message) → result (success or a specific, non-generic error). Never leave the button clickable during an in-flight request - duplicate submissions are a common bug.
  6. Never point the fetch call at a fake endpoint - /api/contact in the template is a placeholder; replace it with the user's real endpoint or clearly tell them where to plug one in.

Validation logic (tested)

function validateForm(data) {
  const errors = {};
  if (!data.name || data.name.trim().length < 2) {
    errors.name = "Informe seu nome (mínimo 2 caracteres).";
  }
  const emailOk = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(data.email || "");
  if (!emailOk) {
    errors.email = "Informe um email válido.";
  }
  if (!data.message || data.message.trim().length < 10) {
    errors.message = "Mensagem muito curta (mínimo 10 caracteres).";
  }
  return errors;
}

Tested against 4 cases (missing name, invalid email, too-short message, all valid) - 4/4 passed, verified with Node before this was written into the skill, not assumed.

Notes

  • Client-side validation is UX, not security - the real endpoint must validate again server-side. Say this explicitly if the user's backend isn't shown.
  • For multi-step forms, persist progress in state (not just in the DOM) so a stray back-button press doesn't lose input.
  • Real <button type="submit"> inside a real <form> - never a <div onclick>, which breaks keyboard and screen-reader use.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.