title: Dynamic Smart date mask while inserting date
body: <p>Is there a way in javascript or jQuery to detect and change dynamically while typing a date for both a key input and a copy and paste to a text box?</p>
  
  <p>I'm trying to create a functional text box which has two digits such as a month. </p>
  
  <p>Since the month can be a number from 1 - 12 I want to enforce the first digit to be a 1 or a 0.</p>
  
  <p>The trick that I'm trying to do however is when the text box first gains focus and a user beging to type a number, if that number is 2 - 9 I want a zero to automatically fill the first spot and then but the 9 in the second spot.</p>
  
  <p>Before I type anything this date input would look like so:</p>
  
  <pre><code>__/__/_____
  </code></pre>
  
  <p>If I type a "1"</p>
  
  <pre><code>1_/__/_____
  </code></pre>
  
  <p>If I type "2" should get</p>
  
  <pre><code>02/__/_____
  </code></pre>
  
  <p>If I type "22" should get</p>
  
  <pre><code>02/2_/_____
  </code></pre>
  
  <p>If I type "77" should get</p>
  
  <pre><code>07/07/_____
  </code></pre>
  
  <p>I would be very interested for in an answer with code or a link to a tool that already does this or a link to a previous post? </p>
  
  <p>Eventually I want to put it in a masked so 7/7/2011 or 7/7/11 or 07/07/2011 will alway fill to 07/07/2011.    In the final final version I am trying to get the year to default to the current decade but have a drop down to each 10 year++ --.</p>