title: JS - Detect when a user clears a field
body: <p>I'm creating a calculator for my current web project, it works very well but as I was playing with it, it came to my attention that clearing the third field caused the script to output NaN. </p>
  
  <p>I'm fairly new to Javascript, and I attempted to do </p>
  
  <pre><code> if($('#field11').val() == '' || $('#field12').val() == '' || $('#field13').val() == ''){
       $('#result1').text('')
   }
  </code></pre>
  
  <p>But that doesn't to fix the issue. I've looked for a solution to this problem, but it's as if no one on the internet has had a problem like this! I need to be able to clear the output (#result1) if any one of the inputs are cleared.</p>
  
  <p>This is my full code:</p>
  
  <pre><code> $(document).ready(function(){
  
       $('#field11').keyup(function(){
           if($('#field12').val() != '' &amp;&amp; $('#field13').val() != ''){
          $('#result1').text(commafy(Math.round( $('#field11').val() + $('#field12').val() / $('#field13').val() * 1.5)) + ",99");
          }
       });
          $('#field12').keyup(function(){
          if($('#field11').val() != '' &amp;&amp; $('#field13').val() != ''){
          $('#result1').text(commafy(Math.round( $('#field11').val() + $('#field12').val() / $('#field13').val() * 1.5)) + ",99");
          }
       }); 
       $('#field13').keyup(function(){
           if($('#field11').val() != '' &amp;&amp; $('#field12').val() != ''){
          $('#result1').text(commafy(Math.round( $('#field11').val() + $('#field12').val() / $('#field13').val() * 1.5)) + ",99");
           }
       });
       if($('#field11').val() == '' || $('#field12').val() == '' || $('#field13').val() == ''){
           $('#result1').text('')
       }
  });
  </code></pre>
  
  <p>Here is the working code on JSFiddle: <a href="https://jsfiddle.net/x7a91bnx/" rel="nofollow">https://jsfiddle.net/x7a91bnx/</a></p>
  
  <p>Thank you!</p>