Sobre a Aula
These attributes play a fundamental role in fields that require numerical input, such as number, range, date, local date/time, month, hour, and week.
By defining the minimum (min) and maximum (max) values, developers have complete control over the range of acceptable values.
By using the “min” and “max” attributes together, it is possible to create a specific range of allowed values for an input field.
<form> <label for="datemax">Enter a date before 1980-01-01:</label> <input type="date" id="datemax" name="datemax" max="1979-12-31"><br><br> <label for="datemin">Enter a date after 2000-01-01:</label> <input type="date" id="datemin" name="datemin" min="2000-01-02"><br><br> <label for="quantity">Quantity (between 1 and 5):</label> <input type="number" id="quantity" name="quantity" min="1" max="5"> </form>
This not only provides an effective way to ensure valid data but also simplifies the user experience by guiding them to provide information within desired limits.
In summary, the “min” and “max” attributes are valuable tools for imposing clear and specific limits on input fields, ensuring that the provided data falls within predefined ranges.
Entrar na conversa