I'm trying to create an order form for a class project where there are 6 items and each item requires a quantity entered. I have the input type as number and the scroll bar displays when clicking into the field but I also want to make sure users cannot manually input a number over 10. I realized we cannot use "getElementById" since id's must be unique and will only fire on the first element with that Id. I've been playing around with getElementByClassName but it's not firing at all. All inputs in the table have the same class, name, and iD assigned. Any suggestions/ideas why this isn't working?
Javascript:
var quant = document.getElementsByClassName("Quantity");
quant.addEventListener("blur", checkquant);
var message = document.getElementsByClassName("quantmsg");
function checkquant() {
if (quant < 11) {
message.textContent = "";
} else {
message.textContent = "Maximum Quantity of 10";
}
}
HTML (one input sample out of the 6 within a table):
<tr>
<td><input type="checkbox" name="DesktopPC" value="DesktopPC">
<label for="DesktopPC">Desktop PC</label>
</td>
<td><label for="QuantityD">Quantity:</label>
<input class="Quantity" type="number" value="0" min="0" max="10" onfocus="inputfocus();">
<div class="quantmsg"></div>
</td>
</tr>