I am writing custom form validation javascript library and I am thinking about correct markup syntax. Let’s say I have an input that requires number between 1 000 and 10 000.
So far, I came up with something like this:
<input class='validate required number' min='1000' max='10000' />
Is this correct way to do it? I have two problems here:
- I don’t like using classes. It feels like misuse. Is it OK to use them like this?
- My custom attributes
minandmaxdon’t validate.
Since HTML5 will support this structure, it might be the best way to go:
Whereby any “data-…” attribute can be used to store more info. You could also attach this data after using script(s)