I have type=number input field and I have set min and max values for it:
type=number
min
max
This work perfect for geographic coordinates when you have general function document EventListener "keydown" in my example i use bootstrap class.
If you want you can create a function with this code but i preferred this method.