HTML <input> แอตทริบิวต์ขั้นต่ำ
ตัวอย่าง
การใช้แอตทริบิวต์ min และ max:
<form action="/action_page.php">
<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"><br><br>
<input type="submit">
</form>
ความหมายและการใช้งาน
แอตทริบิวต์min
ระบุค่าต่ำสุดสำหรับ
<input>
องค์ประกอบ
เคล็ดลับ:ใช้min
แอตทริบิวต์ร่วมกับ
max
แอตทริบิวต์เพื่อสร้างช่วงของค่าทางกฎหมาย
หมายเหตุ:แอตทริบิวต์max
และmin
ใช้งานได้กับประเภทการป้อนข้อมูลต่อไปนี้: หมายเลข ช่วง วันที่ วันที่เวลาท้องถิ่น เดือน เวลา และสัปดาห์
รองรับเบราว์เซอร์
ตัวเลขในตารางระบุเบราว์เซอร์รุ่นแรกที่สนับสนุนแอตทริบิวต์อย่างเต็มที่
Attribute | |||||
---|---|---|---|---|---|
min | 5.0 | 10.0 | 16.0 | 5.1 | 10.6 |
ไวยากรณ์
<input min="number|date">
ค่าแอตทริบิวต์
Value | Description |
---|---|
number | Specifies the minimum value allowed |
date | Specifies the minimum date allowed |
❮ แท็ก HTML <input>