I have a textfield where I’m adding a custom attr called maxchars and a value of 255. I can’t seem to read the value, could someone tell me what I might be doing wrong.
jquery
var textarea = jQuery(this);
var maxlength = parseInt(textarea.attr("maxchars"));
html
<t:TextArea maxchars="255"/>
But it’s not vailid html. Set data in fron of it!
To make it html5 valid, name your attribute
data-maxcharsand use the selector$('[data-maxchars]')Sample:
HTML
JS:
Fiddle