If you use jQuery, why not use its abstractions to the fullest?
eg.
Instead:
$("input#title").get(0).setAttribute("max_length", 25);
$("input#title").get(0).setAttribute(
"onkeypress",
"return limitMe(event, this)");
function limitMe(evt, txt) {
if (evt.which && evt.which == 8) return true;
else return (txt.value.length < txt.getAttribute("max_length");
}
Do it:
$('input#title').attr('maxLength','25').keypress(limitMe);
function limitMe(e) {
if (e.keyCode == 8) { return true; }
return this.value.length < $(this).attr("maxLength");
}
: , IE, , , onKeyPress setAttribute. - .