JSFiddle - React, Tailwind, and code Playground
HTML
<form>
<input id="foo" name="bar" maxlength="10" size="20" placeholder="Enter here.."/>
</form>
<h3>Expected</h3>
The native limit no longer applies.
<h3>Actual</h3>
The native limit applies and stronger than ever. Though the maxLength property is and stays "undefined", somehow the attribtue has changed to maxlength="0".
CSS
body {
font-family: sans-serif;
}
form {
padding: 1em;
}
input {
padding: 0.3em 0.2em;
}
JavaScript
jQuery.fn.fooLimit = function () {
var $el = $(this),
limit = $el.prop('maxLength');
// Unset the native limit, because we're going to use the limit in X way
// X could be, limiting to number of bytes, or number of characters
// including a prefix separated by :, anything.
// For the purpose of this example, though, we won't do anthing else.
$el.removeProp('maxLength');
};
jQuery(document).ready(function ($) {
$('#foo').fooLimit();
});