title: jQuery or Javascript to autoformat phone mask
body: <p>I have a Rails app that I'm recording a <code>text_field</code> as a <code>string</code> which is a phone number that I'd like auto-formatted in the following mask <code>xxx-xxx-xxxx</code></p>
  
  <p>I was searching Stack Overflow and found this <a href="https://stackoverflow.com/questions/10930866/auto-format-phone-number-in-jquery-can-anyone-help-me-please">auto-format-phone-number-in-jquery</a> but the OP was looking to format a mask of <code>xxx-xxx-xxx</code> and I need to figure out how to do a mask of <code>xxx-xxx-xxxx</code></p>
  
  <p>I've borrowed a snipped from this answer and it does work but again formats as <code>xxx-xxx-xxxx</code></p>
  
  <pre><code>$(function(){
    $('#call_caller_phone').keyup(function()
    {
       this.value = this.value.replace(/(\d{3})\-?/g,'$1-');
    });
  });
  </code></pre>
  
  <p>Can anyone assist me with formatting in the <code>xxx-xxx-xxxx</code> mask?</p>