In this article we will learn about some of the frequently asked HTML programming questions in technical like “How to Set focus to first text input in a bootstrap modal after shown” Code Answer’s. When creating scripts and web applications, error handling is an important part. If your code lacks error checking code, your program may look very unprofessional and you may be open to security risks. Error or stack handling on html was simple and easy. An error message with filename, line number and a message describing the error is sent to the browser. This tutorial contains some of the most common error checking methods in HTML. Below are some solution about “How to Set focus to first text input in a bootstrap modal after shown” Code Answer’s.
To focus on the textbox when bootstrap pop-up is open
xxxxxxxxxx
$("#dialog-cancelReasonModal").on('shown.bs.modal', function () {
$(this).find('#txtName').focus();
});
• ID of the bootstrap POP-UP = dialog-cancelReasonModal
• ID of the TextBox = 'txtName'
How to Set focus to first text input in a bootstrap modal after shown
xxxxxxxxxx
$('#myModal').on('shown.bs.modal', function () {
$('#textareaID').focus();
})
/* My solutioin ..
// focus on button close .. so when you press Enter key .. modal closes .. again comunicating with bs.modal only attainable by jq
$(ids.id4).on(`shown.bs.modal`, function(){
$(`#modal-diag1 button`).focus()
})
==============================================================
// check the following for
$("#dialog-cancelReasonModal").on('shown.bs.modal', function () {
$(this).find('#txtName').focus();
});
• ID of the bootstrap POP-UP = dialog-cancelReasonModal
• ID of the TextBox = 'txtName'
How to Set focus to first text input in a bootstrap modal after shown
xxxxxxxxxx
<input value="" autofocus>
// not tested yet
// https://stackoverflow.com/questions/15247849/how-to-set-focus-to-first-text-input-in-a-bootstrap-modal-after-shown