DNB5brims
DNB5brims

Reputation: 30568

Is is possible to have my own tag attribute in the HTML code?

I know the input have the maxlength, but I would like to have minlength as my personal application for define, can I have this abilities? of course, the behavior is implemented by javascript, instead of the browser, can I do so?

Upvotes: 1

Views: 64

Answers (1)

alex
alex

Reputation: 490153

Yes, you can do that.

To make it validate with HTML5, prefix your custom attribute with data-.

You can get the minlength attribute in JavaScript with...

var minLength = +inputElement.getAttribute('data-minlength');

Upvotes: 3

Related Questions