Question

I'm using the timepicker plugin for jquery.

Once users selected a date+time and click on the "Done" button, which basically just closes the dialog, I want the textbox where datetime is set to gain back focus (the current behavior of the plugin is to blur out focus).

This is because on this page I have a set of textboxes and their tab orders are set sequentially. I need the datetime textbox to gain back focus to continue the tab order. otherwise the tab order will restart from the first text input which is inconvenient for the user.

Was it helpful?

Solution

Description

Assuming i understand your question, you can set the focus to your textbox in the onClose event. Please provide more information if this is not the right answer. html or better a jsFiddle would be great.

Sample

$('#MyDatepicker').datetimepicker({
    onClose: function(dateText, inst) {
       $('#MyDatepicker').focus();
    }
});

More Information

Update

If you have several datePickers you can do this.

  1. Gave them all the same css class.
  2. Do this

        $('.MyDatePickerClass').datetimepicker({
            onClose: function(dateText, inst) {
               $('.MyDatePickerClass').focus();
            }
        });
    
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top