title: Jquery if keyup else default value
body: <p>I have a textbox whose value comes from database but if a user changes the value then this value needs to be used in a calculation.</p>
  
  <pre><code>$('#ecost input.ecost').keyup(function(){
      if (!isNaN(this.value) &amp;&amp; this.value.length != 0) {
          var Cost = $(this).val();
      }
  });
  </code></pre>
  
  <p>and</p>
  
  <pre><code>var cost = $('input.ecost1').val();
  </code></pre>
  
  <p>I need if <code>keyup</code> function for user enter value (first code example) else default database value (second code example). How can I write this if/else condition?</p>
  
  <p>i need </p>
  
  <pre><code> if ($('#ecost input.ecost').keyup(function(){
      if (!isNaN(this.value) &amp;&amp; this.value.length != 0) {
          var Cost = $(this).val();
      }
  }); ) 
  else {
  var cost = $('input.ecost1').val();
  }
  </code></pre>
  
  <p>i know in if() code is wrong but above logic how to corrected</p>