autofocus="autofocus"

This public forum is for user-to-user discussions of ASP.NET Maker. Note that this is not support forum.
Post Reply
eftalboza
User
Posts: 38

autofocus="autofocus"

Post by eftalboza »

Hello

To be much more efficient, it would be great if the search field (which I enabled already to be always shown) could have the HTML5 attribut

autofocus="autofocus"

When opening a new page, one could immediately start typing and it will be in the search field without the need to click there. Especially when looking up many records via a barcode reader as we use it, it would be very helpful not to need to click into the search field before each new reading.

Is there any file where I can add this code so that all search fields on my pages always have this attribut?


darkdragon
User
Posts: 151

Post by darkdragon »

Hi there,

just add

// Autofocus in SearchBox
$('#psearch').focus();

in Client Scripts -> Global -> Pages with header/footer -> Startup Script


eftalboza
User
Posts: 38

Post by eftalboza »

What should we do to focus the first field on the add page.?

thank you for your help


darkdragon
User
Posts: 151

Post by darkdragon »

there are multiple solutions (just google for them), but you have to adapt to the one that suits you best.

vanilla JS:

document.forms[0].elements[0].focus();

but this will focus on hidden or read-only fields.

better try sometthing with jQuery:

$(document).ready(function() {
    $('form:first *:input[type!=hidden]:first').focus();
});

darkdragon
User
Posts: 151

Post by darkdragon »

forgot to tell you that if you use placeholder, then it will not show on the first field if you focus by default on it


Post Reply