</> ConvertAtlas Developer Tools
Forms Lesson 9 Beginner 13 min

Form Controls and Validation

Textareas, selects and buttons — plus built-in HTML validation that catches mistakes before submit.

In the last lesson you built a basic form. Now you will add the remaining controls — multi-line text, dropdowns and buttons — and learn how HTML can validate input for free, before anything is even sent.

Textareas for longer text

A single-line input is fine for a name, but for messages or comments you want multiple lines. The <code>&lt;textarea&gt;</code> element gives a resizable, multi-line box. Unlike input, it has a closing tag, and any text between the tags becomes its default content.

HTML · editable
A multi-line text box — try typing in it.

For a list of choices, a dropdown saves space. Use <code>&lt;select&gt;</code> for the menu and an <code>&lt;option&gt;</code> for each choice. The option's <code>value</code> is what gets submitted; the text between the tags is what the user sees.

HTML · editable
A dropdown menu.

Buttons

The <code>&lt;button&gt;</code> element is more flexible than an input button — it can contain text, icons or HTML. Its <code>type</code> matters: <code>submit</code> sends the form, <code>reset</code> clears it, and <code>button</code> does nothing on its own (used with JavaScript).

button typeWhat it does
submitSends the form (default inside a form)
resetClears all fields back to defaults
buttonNothing by itself — for JavaScript

Built-in validation

HTML can check input before the form submits — no JavaScript required. Add <code>required</code> to make a field mandatory. Use <code>type="email"</code> to require a valid email shape. Add <code>min</code>, <code>max</code> and <code>maxlength</code> to limit values, or <code>pattern</code> for a custom rule. The browser shows a helpful message and blocks submission until it is fixed.

HTML · editable
Try submitting empty or with a bad email — the browser stops you.
Validation is not securityHTML validation improves the experience, but it is not security. A determined user can bypass it, so important data must always be checked again on the server. HTML validation is the friendly first line, not the lock.
Client-side (HTML) vs server-side validation
HTML validation
  • Instant feedback
  • No code needed
  • Great user experience
  • Can be bypassed
Server validation
  • Runs after submit
  • Needs back-end code
  • Cannot be bypassed
  • The real safety net
Try it yourself: a validated form

Build a sign-up form in the editable box: a required name (text), a required email, a number field with min and max, a dropdown with three options, and a submit button. Try submitting it incomplete and watch HTML catch the errors.

Quick quiz

1. Which element is a multi-line text box?

2. In a <select>, what gets submitted?

3. How do you make a field mandatory?

4. Is HTML validation enough for security?

5. Which button type sends the form?

Key takeaways
  • Use <textarea> for multi-line text and <select>/<option> for dropdowns.
  • Button types: submit sends, reset clears, button is for JavaScript.
  • Built-in validation: required, type, min/max, maxlength, pattern.
  • HTML validation improves UX but is not security — validate on the server too.