I\'m using datepicker inside my input , my last field is the datepicker input , after validating it i want to set focus on another input inside my form , but the problem is
Here's a modified solution that worked for me:
$(".hasDatepicker").each(function (index, element) { var context = $(this); context.on("blur", function (e) { // The setTimeout is the key here. setTimeout(function () { if (!context.is(':focus')) { $(context).datepicker("hide"); } }, 250); }); });