Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer Validating Input Types | HTML5 Built-in Validation
JavaScript Form Validation

bookValidating Input Types

When you use the type attribute on an HTML <input> element, you enable the browser to automatically check whether the user's input matches the expected format. For example, setting an input's type to email or number tells the browser to enforce certain rules: an email input must look like a valid email address (with an "@" and a domain), and a number input will only accept numeric values. These built-in validations happen before your JavaScript code even runs, helping you catch simple errors early and providing immediate feedback to users.

index.html

index.html

copy

If a user tries to submit the form above with an invalid email address—such as "hello" instead of "hello@example.com"—the browser will automatically block the submission and show a message asking for a valid email. Similarly, if a user enters non-numeric text into the age field, the browser will prevent the form from being sent and may display a warning. This built-in validation improves usability and reduces the amount of custom JavaScript you need to write for simple checks.

question mark

Which of the following input types provide built-in validation in HTML5?

Select the correct answer

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 2. Hoofdstuk 2

Vraag AI

expand

Vraag AI

ChatGPT

Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.

Awesome!

Completion rate improved to 5.56

bookValidating Input Types

Veeg om het menu te tonen

When you use the type attribute on an HTML <input> element, you enable the browser to automatically check whether the user's input matches the expected format. For example, setting an input's type to email or number tells the browser to enforce certain rules: an email input must look like a valid email address (with an "@" and a domain), and a number input will only accept numeric values. These built-in validations happen before your JavaScript code even runs, helping you catch simple errors early and providing immediate feedback to users.

index.html

index.html

copy

If a user tries to submit the form above with an invalid email address—such as "hello" instead of "hello@example.com"—the browser will automatically block the submission and show a message asking for a valid email. Similarly, if a user enters non-numeric text into the age field, the browser will prevent the form from being sent and may display a warning. This built-in validation improves usability and reduces the amount of custom JavaScript you need to write for simple checks.

question mark

Which of the following input types provide built-in validation in HTML5?

Select the correct answer

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 2. Hoofdstuk 2
some-alt