Skip to content
Learn Netverks

Lesson

Step 24/36 67% through track

form-bindings

Form bindings

Last reviewed May 28, 2026 Content v20260528
Track mode
client_vue
Means
In-browser Vue TS
Reading
~2 min
Level
intermediate

This lesson

This lesson teaches Form bindings: the concepts, APIs, and habits you need before advancing in Vue.

Forms are where UX and validation meet—controlled inputs are the React default for predictable state.

You will apply Form bindings in contexts like: Login forms, filters, wizards, and settings panels with two-way binding.

Write TypeScript, click Run—Vue 3 loads from CDN with the template compiler, mountApp shows UI in #app, and printOutput feeds the terminal.

When you can explain the previous lesson's ideas without copying starter code.

Vue forms stay predictable when inputs read from reactive state and write back through the same source. v-model is syntactic sugar for that two-way binding on supported elements—text fields, checkboxes, selects, and radio groups.

Controlled inputs

Bind :value (or :checked) and listen for @input / @change, or use v-model on a ref. The ref is the single source of truth—never let the DOM hold shadow state you do not read on submit.

Modifiers

  • v-model.lazy — sync on change instead of every keystroke
  • v-model.number — coerce to number when possible
  • v-model.trim — trim whitespace on text inputs

Compared to React

React uses explicit value + onChange on every field. Vue’s v-model hides the wiring but the mental model is identical: one reactive value drives the input.

Important interview questions and answers

  1. Q: What does v-model expand to on a text input?
    A: :value="x" and @input="x = $event.target.value" (Vue 3 uses modelValue on custom components).
  2. Q: Why avoid uncontrolled inputs in Vue SPAs?
    A: You lose predictable state for validation, reset, and server sync.

Self-check

  1. Which modifier waits until blur to update state?
  2. Where should validation errors live—in the DOM or in refs?

Challenge

Profile form

  1. Bind name and email with v-model.
  2. Add a checkbox for newsletter opt-in.
  3. Log the object with printOutput on submit.

Done when: terminal shows the same values visible in the form fields.

Tip: Checkbox v-model binds boolean; radio groups need the same v-model on each input with distinct value.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs in your browser in a sandboxed frame. Backend runners appear when this track’s profile allows them.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • v-model on checkbox group?
  • Validation approach?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump