Enforcing the maxlength attribute on mobile browsers
Try this one:
var $input = $('input')
$input.keyup(function(e) {
var max = 5;
if ($input.val().length > max) {
$input.val($input.val().substr(0, max));
}
});
jsFiddle here: http://jsfiddle.net/fttk2/1/
This problem is because predictive text is enabled on your keyboard, disable it and try again