Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Impara Exploring Different Input Types in HTML | HTML Forms and User Input
Ultimate HTML
course content

Contenuti del Corso

Ultimate HTML

Ultimate HTML

1. Understanding Web Development
2. HTML Tags and Attributes
3. HTML Document Structure
4. Working with Media and Tables
5. HTML Forms and User Input

book
Exploring Different Input Types in HTML

HTML provides various <input> elements that enable you to capture different types of data from users. Let's explore some commonly used input types:

email and password

  • type="email": used for email input fields that require a valid email address. The browser automatically validates the email address, prompting the user to correct invalid entries;
  • type="password": used for password fields where the entered text is masked for security. You can also specify minLength and maxLength attributes to set password length requirements.
html

index.html

copy

number

type="number": used for numerical input. You can define a specific range with the min and max attributes and set a specific step value with the step attribute.

html

index.html

copy

telephone

type="tel": intended for inputting telephone numbers, but it does not perform any validation on the input. It is up to the developer to validate the input and ensure it's a valid phone number.

html

index.html

copy

checkbox

type="checkbox": allows the user to select one or more options from predefined choices. The checked attribute makes a checkbox checked by default.

html

index.html

copy

radio

type="radio": creates a set of options where only one option can be selected. A radio button represents each option, and choosing one automatically deselects the others. Each radio button should have a unique value attribute to identify it.

html

index.html

copy

range

type="range": creates a slider control that allows users to select a value within a specific range. You can apply min, max, step, and value attributes to define its behavior.

html

index.html

js

index.js

copy

Note

JavaScript is not the focus of this course, so the logic behind it will be skipped.

date and time

  • type="date": allows users to select a date from a calendar popup;
  • type="time": allows users to input a time in a 24-hour format;
  • type="datetime-local": combines time and date inputs.

Example:

html

index.html

copy

Note

For consistent styling across different devices, ready-made solutions are often used for popup calendars and time inputs.

question mark

What is the main difference between the type="email" and type="password" input fields?

Select the correct answer

Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 5. Capitolo 5
Siamo spiacenti che qualcosa sia andato storto. Cosa è successo?
some-alt