Date picker was not working in mvc razor view

Total Post:44

Points:310
C#
 374  View(s)
Ratings:
Rate this:

I am open a modal popup form but datepicker for DOB was not working.

Here is my code:

<div class="col-md-6">
    <label for="dob">DOB</label>
        <div class='input-group date' id='datetimepicker1'>
            @Html.TextBoxFor(x => x.DOB, "{0:MM/dd/yyyy}", new { @class = "form-control", placeholder = "mm/dd/yyyy" })
                 <span class="input-group-addon">
                    <i class="fa fa-calendar" aria-hidden="true"></i>
                 </span>
                    @Html.ValidationMessageFor(x => x.DOB)
         </div>
/div>  


  1. Post:1

    Points:7
    Re: Date picker was not working in mvc razor view

    Hi Harsh,

    I analyzed your code, you are missing javascript code for datepicker.

    After analyzing your code i have found that javascript code for datepicker is been missing in your line of codes.

     Kindly add the given line of codes in your view bottom as following :

    <script> 
        $(function () {
            $('#datetimepicker1').datepicker({
                viewMode: 'days'
            });
            });
        });
    </script>


      Modified On Dec-06-2017 01:34:06 AM

Answer

NEWSLETTER

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