3 ms·
Luckily it is easy to do validation with javascript if you properly set type=number: if (Number.isNaN(input.valueAsNumber)) { // If only this message
by runarberg 4y ago
Luckily it is easy to do validation with javascript if you properly set type=number:
if (Number.isNaN(input.valueAsNumber)) {
// If only this message could also by localized
input.setCustomValidity("Please type a number");
} else {
input.setCustomValidity("");
}
But double luckily, we don’t even need to do this as we also get this for free, and as a bonus the message is localized.