Answer the question
In order to leave comments, you need to log in
How can I set a field with input type="text" using javascript to only accept numbers with a range of 00 to 60?
You cannot change the field type to input type="number".
Answer the question
In order to leave comments, you need to log in
Look, it's very tough of course.
https://jsfiddle.net/twobomb/p7027rv3/
Only check for JS: jsfiddle.net/IonDen/sbLktg1f
var input = document.getElementById("test");
var check = function () {
var val = +this.value;
if (typeof val === "number" && val < 0) {
this.value = 0;
}
if (typeof val === "number" && val > 60) {
this.value = 60;
}
if (isNaN(val)) {
this.value = "";
}
};
input.addEventListener("keyup", check, false);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question