I have a user input and I only want them to be able to enter a number between 0-3. currently I have it restricted to only numbers and a maxlength of 1 but how can I tweak this to only allow 0-3 to be entered in the input? I understand I can change the type to number, set a min and a max but I have javascript that prevents this form from submitting so I don't think that will work in my situation.
Jquery
$(document).on("keypress", ".form-control", function(evt) {
evt = (evt) ? evt : window.event;
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
return false;
}
return true;
});
input
<input data-src='ROOF_ASSEMBLY' class="form-control" type="text" maxlength="1">