Ask coding questions

← Back to all posts
Validating number input

Hello! I have the following two input number HTML controls:

and the following JS:

I want my controls doesn't accept any number outside [0..60] range. I don't understand why validation fails.


for-loops and function assignments don't go well together. I'd try these changes:

  • Instead of using function assignment, use addEventListener()
  • Use the change event instead of keyup
  • Use let instead of const for your loop iterator