JavaScript input value will return string if you do var x = document.getElementById('demo').value; document.write(typeof(x));
will return string, to convert the value of x to number parseFloat(x); document.write(typeof(x)); This will return Number.