I have an issue which is that I have a class that validates an input to only allow numbers:
$(function() {
$( '.validate_numbers' ).bind('keypress', function (e) {
//console.log(e.which);
return (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) ? false : true;
});
});
But when I append another input:
$('#persons').append('<input type="text" class="validate_numbers">');
with the same class it doesn't validate the input and allows any character you type.
How can I invoke jquery to apply the keybind to the inputs that I append?