JQuery UI Datepicker loses focus when selecting date with mouse

后端 未结 10 1551
情歌与酒
情歌与酒 2021-02-01 02:16

I am using JQuery ui with datepicker and when a user tabs on to a field, they appropriately get the calendar pop up.

  1. User tabs (via key onto field
  2. User s
10条回答
  •  说谎
    说谎 (楼主)
    2021-02-01 02:28

    I was able to get the focus to the next input field after pressing enter (which selects todays date by default) or when clicking a date from the calendar by using this

    $(".jqDateField").datepicker('option', {
        dateFormat: 'mm/dd/y', onClose: function () {
            $(':input:eq(' + ($(':input').index(this) + 1) + ')').focus();
        }
    });
    

    This may be required to set focus on the next text input incase you have a select or an input button in the "way"

    $(':input[type="text"]:eq(' + ($(':input[type="text"]').index(this) + 1) + ')')
    

提交回复
热议问题