neha tj
neha tj

Reputation: 97

datepicker resetting the value

I am trying to perform the following actions on the datepicker:

1) click on the input field of the datepciker and navigate to the next month (say March) 2) I do not do any selection but close the datepicker. 3) I come back to the datepicker field and i still see the datepiker in March

Is there a way to reset the display back to February(current month)?

I am using the following code on ng-focus for the input field, but it doesn't seem to work:

View:

<input class="inputFilterMinTemp" id = "st_date" type="text" ng-    model="name.StartDate" ng-focus = "resetCal()" placeholder="Search"  />

Controller:

$scope.resetCal = function()
{
$('#st_date').datepicker("setDate",null);
};

$scope.init = function()
{
           $('#st_date').datepicker({
                    format: "dd-M-yyyy",
                    autoclose: true
                }).on('changeDate', function(e) {

                });
};

Any idea how i can do this?

Upvotes: 2

Views: 1142

Answers (2)

neha tj
neha tj

Reputation: 97

This worked for me.

  $('#st_date').on('hide', function(){       

            if($('#st_date').val() == "")
            {
            $('#st_date').datepicker('setDate',null);
            }
}).datepicker();

If no selection has been made, reset back to the current month on click of the date picker again

Upvotes: 2

Gomzy
Gomzy

Reputation: 431

try this:

 $("#end_date").datepicker({
        dateFormat: 'dd/mm/yy',
        "setDate": currentDate
    })

Upvotes: 0

Related Questions