# Multi-step Order Form

An order moves through three steps while retaining earlier answers.

## Try it

Enter a cover title, choose a format, and review the proof. Go back to edit either choice.

## Interaction details

The three steps are title, format, and review. Leaving the title empty shows an error and focuses the field. The review reflects the entered title and selected format.

## Platform controls

- iOS · Type a cover title and tap a format to complete the proof.
- Android · Go to the next step and return to check that the previous entries are still there.
- PC · Tab between fields and use the arrow keys to select a format.

## Where to use it

Custom orders, bookings, and enrollment forms that benefit from shorter steps.

## Implementation prompt

> Validate each step, keep completed fields when navigating back, and summarize the actual selections.

## Sources and credits

[W3C WAI · Multi-page Forms](<https://www.w3.org/WAI/tutorials/forms/multi-page/>)

## Standalone HTML

Save the code below as an HTML file and open it in your browser. The example works offline.

```html
<!doctype html>
<html lang="en"><head><script>if(new URLSearchParams(location.search).get('reduce')==='1')document.documentElement.classList.add('motion-reduced');</script><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Little Book Order</title><style>
*{box-sizing:border-box}body{margin:0;background:#eeece3;color:#172b3e;font:15px/1.45 system-ui,sans-serif;display:grid;align-items:center;min-height:100vh}main{width:min(760px,100%);margin:auto;padding:clamp(16px,4%,34px)}.board{display:grid;grid-template-columns:minmax(130px,.65fr) minmax(0,1.75fr);background:#fffdf4;box-shadow:0 12px 38px #29334220;min-height:355px}.cover{display:grid;position:relative;overflow:hidden;align-items:end;padding:22px;color:#fff9e8;background:#203a50;isolation:isolate}.cover:before{content:"";position:absolute;z-index:-1;width:180%;height:90%;left:-55%;top:-10%;background:repeating-radial-gradient(circle at 40% 28%,#ff854f 0 5px,transparent 6px 13px);transform:rotate(-17deg)}.cover span{font:italic 400 clamp(29px,4vw,48px)/.97 Georgia,serif;letter-spacing:-.055em}.order{padding:clamp(19px,4vw,36px);align-self:center;min-width:0}h1{margin:0 0 13px;font:700 clamp(25px,4vw,34px)/1.17 system-ui;letter-spacing:-.065em}ol{display:grid;grid-template-columns:repeat(3,1fr);gap:5px;list-style:none;margin:0 0 17px;padding:0}li{border-bottom:3px solid #b8bbb5;color:#555d61;padding:4px 0;font-size:12px}li[aria-current=step],li.done{border-color:#274f67;color:#193b53;font-weight:750}h2{font-size:17px;letter-spacing:-.035em;margin:0 0 8px}label{font-size:14px}.title-input{width:100%;min-height:44px;border:1px solid #87969e;border-radius:2px;padding:10px 12px;font:inherit;color:inherit;background:#fff}.title-input[aria-invalid=true]{border-color:#a43b22}.error{margin:4px 0 0;font-size:13px;color:#9d341f}.sizes{display:flex;gap:7px}.sizes label{background:#f1f0e6;border:1px solid #9aa5a5;display:flex;align-items:center;justify-content:center;padding:11px;min-height:46px;gap:5px;flex:1;cursor:pointer}.sizes label:has(input:checked){border-color:#264a61;background:#e3ecee}.sizes input{accent-color:#274f67}.tools{display:flex;justify-content:space-between;gap:8px;margin-top:18px}.tools button{min-height:44px;cursor:pointer;color:inherit;border:1px solid #87969e;padding:8px 15px;background:transparent;font:650 14px system-ui}.tools .primary{background:#23465e;border-color:#23465e;color:#fffdf6;margin-left:auto}button:focus-visible,input:focus-visible,[tabindex="-1"]:focus-visible{outline:3px solid #a84920;outline-offset:2px}.pane{animation:enter .24s ease-out}.receipt{margin:6px 0}.receipt div{display:grid;grid-template-columns:54px 1fr;gap:4px;padding:5px 0;border-bottom:1px solid #d3d4cb}.receipt dt{color:#53616b}.receipt dd{margin:0;font-weight:650;overflow-wrap:anywhere}.complete{font-size:14px}.motion-reduced .pane{animation:none}@keyframes enter{from{opacity:.4;transform:translateX(11px)}}@media(prefers-reduced-motion:reduce){.pane{animation:none}}@media(max-width:480px){.board{grid-template-columns:1fr;min-height:0}.cover{min-height:62px;padding:11px 18px}.cover:before{width:80%;height:330%;left:35%;top:-90%}.cover span{font-size:26px}.cover br{display:none}.order{padding:18px}}
</style></head><body><main><div class="board"><div class="cover" aria-hidden="true"><span>Field<br> Notes</span></div><form class="order" id="order" novalidate><h1>Little Book Order</h1><ol id="steps" aria-label="Order steps"><li>1. Cover</li><li>2. Format</li><li>3. Proof</li></ol>
<section class="pane" data-step="0"><h2><label for="bookTitle">Cover title</label></h2><input id="bookTitle" class="title-input" required maxlength="40" placeholder="e.g. Notes from a Sunday" autocomplete="off"><p class="error" id="error" role="alert" hidden></p></section>
<section class="pane" data-step="1" hidden><h2 id="sizeHeading" tabindex="-1">Book size</h2><div class="sizes" role="radiogroup" aria-labelledby="sizeHeading"><label><input type="radio" name="size" value="A5" checked>A5</label><label><input type="radio" name="size" value="B6">B6</label></div></section>
<section class="pane" data-step="2" hidden><h2 tabindex="-1">Review proof</h2><dl class="receipt"><div><dt>Cover</dt><dd id="previewTitle"></dd></div><div><dt>Format</dt><dd id="previewSize"></dd></div></dl></section>
<section class="pane" data-step="3" hidden><h2 tabindex="-1">Your proof is ready.</h2><p class="complete">You can still edit the cover title and format.</p></section>
<div class="tools"><button type="button" id="back" hidden>Back</button><button type="submit" id="next" class="primary">Next step</button></div></form></div></main><script>
(()=>{
  const form=document.getElementById('order'), input=document.getElementById('bookTitle'), error=document.getElementById('error');
  const back=document.getElementById('back'), next=document.getElementById('next');
  const panes=[...form.querySelectorAll('[data-step]')], steps=[...form.querySelectorAll('li')];
  let stage=0;
  function render(focus){
    panes.forEach((pane,i)=>{pane.hidden=i!==stage;});
    steps.forEach((item,i)=>{item.classList.toggle('done',i<stage);if(i===stage)item.setAttribute('aria-current','step');else item.removeAttribute('aria-current');});
    back.hidden=stage===0||stage===3;next.textContent=['Next step','Review proof','Finish proof','Edit'][stage];
    document.title=(stage===3?'Done':(stage+1)+' / 3 steps')+' · Little Book Order';
    if(stage===2){document.getElementById('previewTitle').textContent=input.value.trim();document.getElementById('previewSize').textContent=form.elements.size.value;}
    if(focus)(stage===0?input:panes[stage].querySelector('h2')).focus();
  }
  function clearError(){error.hidden=true;error.textContent='';input.removeAttribute('aria-invalid');input.removeAttribute('aria-describedby');}
  input.addEventListener('input',()=>{if(input.value.trim())clearError();});
  back.addEventListener('click',()=>{if(stage>0){stage--;render(true);}});
  form.addEventListener('submit',e=>{
    e.preventDefault();
    if(stage===0&&!input.value.trim()){
      error.hidden=false;error.textContent='Enter a cover title.';input.setAttribute('aria-invalid','true');input.setAttribute('aria-describedby','error');input.focus();return;
    }
    clearError();stage=(stage+1)%4;render(true);
  });
  render(false);
})();
</script></body></html>
```
