Select portion of input/string instead of all of it
<p>I have an input that holds a date value like so</p>

<pre><code>03/15/2012
</code></pre>

<p>I am trying to select only portions of the the value instead of the whole thing. For instance if I click the spot before 2 in 2012 the year 2012 will be selected not the whole date (same for is true for months and day).</p>

<p>This is the code I am working with now</p>

<p>html:</p>

<pre><code>&lt;input class = "date-container" /&gt;
</code></pre>

<p>javascript/jquery:</p>

<pre><code>$('.date-container').on('select', function (e)
    e.preventDefault()
    this.onselectstart = function () { return false; }; 
})

$('.date-container').on('focus', function ()
{
    if (document.selection) {
        this.focus();
        var Sel = document.selection.createRange();
        Sel.moveStart('character', -this.value.length);
        CaretPos = Sel.text.length;
    }

    // Firefox support

    else if (this.selectionStart || this.selectionStart == '0')
        switch (this.selectionStart) {
        case 0:
        case 1:
           this.selectionStart = 0;
           this.selectionEnd = 1;
           break;
     }

}
</code></pre>

<p>I have tried a couple things so far. The code above is attempting to prevent the normal select action then based on where the focus is, select a portion of the string(I only have the switch statement options for the month portion, but if it worked I would do the same for day and year). This may be the wrong way to go about it. </p>

<p>Things to note:</p>

<p>By select I mean highlight.</p>

<p>I do not want to use plugins. </p>
