Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 74020

Why typeof not working inside if statement

$
0
0

I'm working on input validation, I dont want to use RegExp but I keep wondering why typeof is not working inside if statement or is anything wrong with my code

function myDom(){
    var message = document.getElementById('show');
    var xx = document.getElementById('demo').value;
    try{
        if(xx === "") throw "can not be empty";
        if(typeof xx === "number") throw "can not be number";
        //if(xx < 100) throw "less than hundreds!"
   }catch(err){
       message.innerHTML = "input " + err;
   }
}

Viewing all articles
Browse latest Browse all 74020

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>