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