Textbox field autofocus is not working in mobile screen.

0
Hi, I'm trying to achieve the Autofocus functionality on the text box field while the page is getting opened; the textbox should be autofocused, and the cursor should trigger on the particular textbox field.   For Autofocus, here I've kept tabindex as a '1.'.  It's working sometimes in desktop view but didn't work on mobile screens.     Can anyone suggest the exact solution ?
asked
3 answers
0

Hi Harsh,

     To enable the autofocus functionality you need to add a HTML snippet and a javascript in the page which contains text box you need focus and add a unique class for that text box for eg(pgno). I have attached the image and Javascript below for your referance.

image.png

document.addEventListener("DOMContentLoaded", function() {    const inputField = document.querySelector('.pgno');    if (inputField) {        inputField.focus();    }});

answered
0

Screenshot 2024-12-17 095510.pngScreenshot 2024-12-17 095523.png

Screenshot 2024-12-17 095539.png

 

Snapshot of Code.

answered
0

Hi Harsh,

You have to build your custom widget for mobile screen with autofocus functionality.

Then you will be able  to use autofocus functionality.

 

Idea :-

Build your custom mobile widget with bydefault 4 text input but make dynamic pass the variable from outside so you can make them 6,7,8 textInput according to your need.

Apply your autofocus logic inside the code.

 

I hope you like the answer

 

answered