$('.licensetable :text').live('keydown', function (event) {
if ((event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105) && (event.keyCode != 8)) {
event.preventDefault();
}
});
I only allow numbers. This works. But if i log
$(this).val().length
Its obviously “one step after”. If i bind the keyup event, i get the correct number. But then i cant disable the keypress event. My goal is to disable the input after a certain amount of numbers has been entered. Hope you get the idea. Thanks
You can simply set the attribute
maxlength='X'on the input field.See it in action.