Recently, I needed to implement a very straight forward HTML input. I know we do this kind of thing all the time, but I had some interesting insights I’d like to share. Check these input elements and validation notes:
Pretty simple, nothing too challenging. However, when I tried those
max HTML 5 attributes, I got a very unexpected behavior: nothing. Input constraints work only when users set the value by using the browser widget, but they don’t prevent typed values.
Given those alternatives, I chose the second one and tried to write the lightest and simplest workaround for making
max attributes work as expected. See:
Even being super simple, the approach above seems like something that should not be required.
Maybe I’m misunderstanding the purpose of
Anyway, what you think? I’d appreciate some ideas :-)