The right way for custom HTML attributes

I am writing a JavaScript library to validate the form, and I am thinking about the correct markup syntax. Say I have an entrance that requires a number from 1,000 to 10,000.

So far I have come up with something like this:

<input class='validate required number' min='1000' max='10000' />

Is this the right way to do this? Here I have two problems:

  • I don't like classes. This is like abuse. Can I use them like this?
  • My custom attributes minand maxare not checked.
+3
source share
3 answers

Since HTML5 will support this structure, this may be the best way:

<input data-validate="very-yes" data-min="1000" data-max="10000"/>

"data -..." . script (s)

+5

. , Javascript CSS .

HTML . class , .

, "number-1000-10000", Javascript .

0

jQuery Validation, , , (, max min ) JSON.

0

Source: https://habr.com/ru/post/1733863/


All Articles