How to Set focus to first text input in a bootstrap modal after shown

To set focus to the first text input in a Bootstrap modal after it is shown, you can use JavaScript. Here's an example:

$('#myModal').on('shown.bs.modal', function () {
  $(this).find('input[type="text"]').first().focus();
});

In this example, #myModal is the ID of your modal element. The shown.bs.modal event is triggered when the modal is fully shown. Inside the event handler function, we use the find method to select the first text input element within the modal using the input[type="text"] selector. Then, we call the focus method to set the focus to that input element.

Make sure you have included the jQuery library and the Bootstrap JavaScript file in your HTML document for this code to work properly.

That's it! The first text input in your Bootstrap modal will now receive focus automatically when the modal is shown.