I'd like to validate an input field within a preconfigured range of numbers. Only numbers from 1 up to 24 are allowed.
How can I do?
With a custom solution like this:
$('.field').keypress(function(event) {
var val = parseInt($(this).val()) + HERE_I_SHOULD_SUM_THE_NEWLY_ADDED_DIGIT;
if(val < 1 || val > 24) event.preventDefault();
});
I'm able to retrieve the current input value. How can I add the newly added digit?