Extending from comment:
You have a typo in your code. Change this
<input oninvalid="setCustomValidity('Please enter a number between 1 and 999.'
oninput="setCustomValidity('')")">
to this
<input oninvalid="setCustomValidity('Please enter a number between 1 and 999.')"
oninput="setCustomValidity('')">
Should fix the problem.