I am having an issue with the empty string else if statement for some reason even if I submit an empty string I get that my empty string is still a number even if it is not true or false its just an empty string I just want JS to detect that if the .value is empty to tell the user it is empty simply.
function isNotANumber() {
let isNan = document.querySelector("#nan");
if (isNaN(isNan.value) == true) {
console.log(isNan.value + " is not a number");
}
else if (isNaN(isNan.value) == false){
console.log(isNan.value + " is a number");
}
else if ( isNan.value == ""){
console.log("nothing to submit");
}
}
body {
padding: 0;
margin: 0;
background: #518688;
}
b {
color: darkturquoise;
}
input,button{
padding:5px;
boder:none;
outline:none;
}
<main id="NaN">
<input id="nan" type="text"><button onclick="isNotANumber()">submit</button>
</main>