title: Trim the last digit only if numeric entered.
body: <pre><code>     applicantAddressZipCode.subscribe(function (newValue) {
      if (newValue != undefined &amp;&amp; newValue != '') {
  
          applicantAddressZipCode(formatZipCode(newValue));
          var dataValue = String(applicantAddressZipCode().replace(/[^\/\d]/g, ''));
          if (dataValue &gt; 9999999999999.99 || dataValue &lt; 0) {
              applicantAddressZipCode('');
          }
  
          if (loading == false) {
              sendCommand('SAVE');
          }
      }
  });
  
  
  
  function formatZipCode(value) {
  
      value = value.replace(/[^\/\d]/g, '');
      var z = /(\d{5})-?(\d{4})/
      if (value != undefined &amp;&amp; value != '') {
          return value = value.replace(z, "$1-$2")
      }
  
  
      else {
          return value;
      }
  };
  </code></pre>
  
  <p>I have created a function for zipcode inputs. The function works perfectly fine if user enters 12345-6789 and also 12-3456789 would result to 12345-6789. My problem is when user enters only numbers such as 1234567890, the function would go to 12345-67890. I would like to create a function to trim/slice the last digit when ONLY in the case numbers entered with out the hyphen. I would really appreciate your help! </p>