Q: Condition that should be true is false (JS) I have some JS and HTML code. When the user hits the submit button, I want to know which numerical input box (input type="number"/>) has text. My conditional statement is: document.getElementById("fallen").value != 0 || document.getElementById("fallen").value != "". This, for some reason, doesn't work. I tried using document.getElementById("fallen").value == null.
Any help is appreciated, thanks in advance!

A: The value of any input will always be a string. The statement is working as expected, but you can make one tweak to make it work based on your requirements:
parseInt(document.getElementById('fallen').value, 10) !== 0
or
document.getElementById('fallen').value !== '0'

A: something like that ?
const inputs = document.querySelectorAll('input[type=number]')
document.querySelector('input[type=submit]').addEventListener('click', () =>{
    inputs.forEach( o => {
        if( o.value ) console.log(o.getAttribute('name'))
    })
})

https://codepen.io/Capse/pen/ZxrWwe

A: see that code , i think this is what you need


function compare(){
  var input =$('input[type="number"]')
  if(!input.val() || input.val()==0){
    console.log ('empty');
  }
  else{
    console.log('the content is '+input.val());
  }
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type='number' >
<button onclick=compare()>check</button>



A: Check the field using regex like:
If (/^[0-9]{1,}$/.test(myvalue)) console.log('is a number')
else console.log('is not numerical')
Note: Regex test function works also when the myvalue is equal to null.
