- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML min Attribute
The min attribute of the <input> element is used to set the minimum value for <input>. Both min and max are used to set a range of value for input element with type number, date, datetime, range, etc. It introduced in HTML5.
Let us now see an example to implement the min attribute of the <input> element. Here, we have set min as 1, therefore a user cannot enter an ID less than 1−
Example
<!DOCTYPE html> <html> <body> <h2>Log in to your account</h2> <form action="" method="get"> Id: <input type="number" name="id" min="1" max="10"><br> Password: <input type="password" name="pwd"><br> DOB: <input type="date" name="dob" autofocus><br> <button type="submit" value="Submit">Submit</button> </form> </body> </html>
Output
In the above example, we have created a form with some fields and a button−
<form action="" method="get"> Id: <input type="number" name="id" min="1" max="10"><br> Password: <input type="password" name="pwd"><br> DOB: <input type="date" name="dob" autofocus><br> <button type="submit" value="Submit">Submit</button> </form>
The min attribute is set for the id input type number. Min value is set as 1, therefore user won’t be able to enter a value less than 1−
Id: <input type="number" name="id" min="1" max="10">
Advertisements