AUTO FORMAT DATE OF UNITED STATES FORMAT IN MVC 4

Mark Devid

Total Post:102

Points:714
Posted by  Mark Devid
 1612  View(s)
Ratings:
Rate this:

Hi Expert!

I have one textbox in my MVC 4 project. In this textbox user entered date of US format. I want to auto set US format date during entered or after leave the textbox.

US format date as following

12/31/1989

Please help me!

Thanks in advance!

  1. AVADHESH PATEL

    Post:604

    Points:4228
    Re: auto format date of united states format in MVC 4

    Hi Mark!

    You could try following line of code

    <script src="../../Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.maskedinput.js" type="text/javascript"></script>
    <script type="text/javascript">
        jQuery(function ($) {
            $("#date").mask("99/99/9999");
        });
    </script>

    @Html.TextBox("date", null)

    Note:
    "jquery-1.7.1.min.js" provided by MVC application
    "jquery.maskedinput.js" you can download from following link

    https://raw.github.com/digitalBush/jquery.maskedinput/1.3.1/dist/jquery.maskedinput.min.js

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!