0

I'm trying to use bootstrap-datetimepicker from datetimepicker, but when the date picker is displayed, this covers the input.

enter image description here

enter image description here

The code that I use is something like this:

       <div class="col-md-6" >
            @Html.LabelFor(model => model.BeginDate)
            <div class="form-group" id="">
                @Html.TextBoxFor(model => model.BeginDate,  new { @class = "form-control" , @id="datetimepicker"} )                        
            </div>
            @Html.ValidationMessageFor(model => model.BeginDate)
        </div>   

I initialize the Datetimepicker like this:

$(document).ready(function ()
    {
        $("#datetimepicker").datetimepicker({
            defaultDate: '',
            showTodayButton: true,
            format: 'dd-mm-yyyy',
            showClose: true,
            showClear: true,
            toolbarPlacement: 'top',
            stepping: 15,
            autoclose: true,
            startView:3,
            minView: 2,
            language: 'es'
        });
    });

Bootstrap v3.0.2 ASP MVC 5

2
  • whats your bootstrap version ? Commented Oct 24, 2017 at 23:36
  • @Aaqib I'm using Bootstrap v3.0.2. Commented Oct 24, 2017 at 23:40

1 Answer 1

1

I believe your issue is because you are missing a div wrapping your control the class “input-group”. This gives it a relative position which is required as the picker is positioned absolute.

The docs have the following example

<div class="form-group">
      <div class='input-group date' id='datetimepicker1'>
             <input type='text' class="form-control" />
                    <span class="input-group-addon">
                        <span class="glyphicon glyphicon-calendar</span>
                    </span>
      </div>
</div>

https://eonasdan.github.io/bootstrap-datetimepicker/

Sign up to request clarification or add additional context in comments.

1 Comment

You are right, I was forgot put another div surrounding the input, and initialize that div.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.