Search code examples
htmltextboxtext-align

html How to show last character in limit width textbox


I want to show in text box as "/11/02" BUT now it show as "2016/"

.date {
        width: 40px;
        text-align: justify;
        text-align-last: end;
    }

<input id="date" name="date" class="date" tabindex="-1" readonly="readonly" type="text" value="2016/11/02">

capture textbox with width 40px


Solution

  • You can use jquery for this.

    <script>
        var date = $(".date").val();
        var last = date.substr(date.length - 6); 
        $(".date").val(last);
    </script>