I have a input that i want to recive any number (dont matter if its negative, float, long) i code this to now allow null, undefined or empty values, but if I enter 0 it is read as empty
const inputElement = Number(document.getElementById("inputNumber").value);
if (!inputElement) {
window.alert("Insira um valor válido");
return;
}
i 已经尝试了这项工作,但又做了大量工作。
if (!inputElement && inputElement != 0){
window.alert("Insira um valor válido");
return;
}
是否有任何人知道如何区分零与空洞或反之亦然?