Home > Software engineering >  Date picker window is not close
Date picker window is not close

Time:01-05

I have a date picker but When I clicked date picker input and if I didn't choise any date then when I go outside the input, date picker window is not close. Also this problem just is there in IE.

My code is below;

  @Html.TextBox("Birthdate", null, new { @class = "form-control date-picker input-mask-date", placeholder = "Doğum Tarihi", required = true, id = "dtBirthDate" })

Script side;

$(".input-mask-date").mask("99.99.9999");

if I didn't choise any date then when I go outside the input, date picker window is not close.

enter image description here

CodePudding user response:

As you mentioned this is an issue with IE. However, you can add a custom function to check when one leaves or clicks outside the datepicker to hide it.

$('.date-picker').on('blur', function() {
  $('.date-picker').hide();
});

You can equally use focusOut for the event listener and also fadeOut / slideUp if they work on date pickers.

CodePudding user response:

I solved this problem like that;

$('#dtBirthDate').on('focus', function () {
    $(this).mask("99.99.9999");
});

$("#dtBirthDate").focusout(function () {
    $(this).unmask();
});
  •  Tags:  
  • Related