I need to know what the different parts of this JavaScript code means..

var x=document.getElementById("demo").value;     
if(x==""||isNaN(x))                              

I know what the result of the code is but I need to know what things like; 'var', '(x==""||isNaN(x))
I know what the 'document.getElementById("demo").value;' means but the '(x==""||isNaN(x)) i don't understand

var means variable, it just tells JS that you want x to be a variable holder. So this takes the value of the demo element and stores it in x. It than checks to see if x is blank (x=="") or (||) if x is Not a Number (NaN).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.