Thuộc tính form của <input type="month"> trả về tham chiếu đến phần tử <form> chứa input tháng đó. Thuộc tính **chỉ đọc**.
Cú pháp
monthInput.form
Ví dụ: Xác định form chứa input month
<!DOCTYPE html>
<html>
<head>
<style>
body { text-align: center; background: #363946; color: white; font-family: sans-serif; padding: 20px; }
form { margin: 2.5rem auto; max-width: 400px; }
button {
background-color: #dc3545; border: none; color: white;
padding: 8px 16px; border-radius: 5px; font-size: 1rem; cursor: pointer;
}
.show { font-weight: bold; font-size: 1.2rem; margin-top: 15px; }
</style>
</head>
<body>
<h1>Demo form Property (Month)</h1>
<form id="Form-1">
<fieldset>
<legend>Form 1</legend>
<input type="month" class="monthInput">
</fieldset>
</form>
<button onclick="identifyForm()">Xác định Form chứa Month</button>
<p id="result" class="show"></p>
<script>
function identifyForm() {
var formId = document.querySelector(".monthInput").form.id;
document.getElementById("result").textContent = "Chào! Tôi thuộc " + formId;
}
</script>
</body>
</html>
Kết quả
Form có input month:

Nhấn nút xác định:

💡 Ứng dụng: Hữu ích khi xử lý nhiều form trên một trang, cần biết input month thuộc form nào để submit AJAX đúng endpoint.