How can I use autofocus in form fields

Hi all,

How can i set autofocus in a doctype form to automatically get focus on an input when the page loads?

@NCP Hello Nihantra, Is there anyway you can help with this also I would like to add to query. I want to add autofocus to the ID search in listview and Also in form


frappe.ui.form.on('Yourdoctype', {

refresh: function(frm) {

// Set autofocus on the "subject" field

var subjectField = frm.fields_dict.subject.$input;

subjectField.focus();

}

});

For In form

frappe.listview_settings['Yourdoctype'] = {
    onload: function(listview) {
		var nameFilterField = $('.form-group[data-fieldname="name"] input');
		nameFilterField.focus();
        
    }
};

in List view