แอตทริบิวท์ max ของ <input> ใน HTML
แอตทริบิวท์ max ขององค์ประกอบ <input> ใช้สำหรับกำหนดค่าสูงสุดสำหรับ <input> ทั้ง min และ max ใช้ร่วมกันเพื่อกำหนดช่วงค่าสำหรับองค์ประกอบ input ที่มี type เป็น number, date, datetime, range ฯลฯ ฟีเจอร์นี้ถูกนำมาใช้ตั้งแต่ HTML5
ตัวอย่าง
<!DOCTYPE html>
<html>
<body>
<h2>เข้าสู่ระบบบัญชี</h2>
<form action="" method="get">
ID - <input type="number" name="id" min="1" max="10"><br>
รหัสผ่าน - <input type="password" name="pwd"><br>
วันเกิด - <input type="date" name="dob" autofocus><br>
<button type="submit" value="Submit">Submit</button>
</form>
</body>
</html>
ผลลัพธ์

ในตัวอย่างข้างต้น เราได้สร้างฟอร์มพร้อมฟิลด์ต่างๆ และปุ่ม:
<form action="" method="get"> ID - <input type="number" name="id" min="1" max="10"><br> รหัสผ่าน - <input type="password" name="pwd"><br> วันเกิด - <input type="date" name="dob" autofocus><br> <button type="submit" value="Submit">Submit</button> </form>
แอตทริบิวท์ max ถูกกำหนดสำหรับ input ประเภท number ของ ID ค่าสูงสุดถูกตั้งเป็น 10 ดังนั้นผู้ใช้จะไม่สามารถป้อนค่ามากกว่า 10 ได้:
ID - <input type="number" name="id" min="1" max="10">