Update:
You can use only jQuery.
$(document).ready(function () { $("input").attr('maxlength', '5'); });
If you really need an automatic method, you can use a combination of css and javascript.
Javascript / jquery
$(document).ready(function () {
CSS
.inputMaxLength { }
HTML
<input type="text" id="textbox" class="inputMaxLength" name="textbox" />
A bit of a hack, but it works. As far as I know, there is no css solution.
source share