Skip to main content

Practical Exercise 20: Forms with Date and Number Fields

Discover how to create HTML forms that include date fields<input type="date">and number<input type="number">This practical exercise teaches you how to implement modern, useful, and accessible input controls to improve the user experience in web forms.

Activity

Create an HTML form that includes date fields.<input type="date">and number<input type="number">Also add a button to submit the form.

Interactive Solution

Solution with complete HTML code

HTML
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8" />
<title>Formulario con Fecha y Número</title>
</head>
<body>
<h2>Formulario con Fecha y Número</h2>
<form>
<label for="nombre">Nombre:</label>
<input type="text" id="nombre" name="nombre" />
<br />
<label for="fecha-nacimiento">Fecha de Nacimiento:</label>
<input type="date" id="fecha-nacimiento" name="fecha-nacimiento" />
<br />
<label for="edad">Edad:</label>
<input type="number" id="edad" name="edad" min="1" max="120" />
<br />
<label for="email">Correo Electrónico:</label>
<input type="email" id="email" name="email" />
<br />
<button type="submit">Enviar</button>
</form>
</body>
</html>
info

📘Learn more about this topic here👉 Creating forms with HTML