How to Set Focus on a textbox when opening a page?

0
Hi everyone,   I’m trying to implement a page where if we open the page, the focus will be directly on a textbox so that we don’t have to click it in order to input a text inside. Is there any way to do that?   Thanks in advance
asked
4 answers
1

Hi Jonathan,

You could experiment with setting the tabIndex on the input that you want to focus. TabIndex is the setting that manages focus, also on initial page load. 

It should also automatically focus the first text box on a page. Perhaps there is an element before that which is taking over? You can use document.activeElement to find out which element currently has the focus.

answered
0

Hello Jonathan Djuwandi,

There is no default tool in Mendix to allow you to manage focus, you would have to rely on a widget or js/jQuery. Here's a small example with jQuery "$('. my-field'). focus();" you can drop this in an HTML snippet widget as jQuery and it should do the trick. Hope this helps!

answered
0

Hi Mohamed,

 

Here is the screenshot. So, my current plan is to try to focus on Username input text field on opening the page (solved by setting the tab index). Then perhaps after inputting the first textfield, I want to move to the password input field automatically with either 2 options:

  1. On Change event and set the on change behavior to apply after some ms or
  2. On change event and set if the character contains something then it will trigger to move to the password field.

I just need to know how to set focus to the second one using whats available in Mendix for now.

 

Best regards,

 

Jonathan

answered
0

Hi Jonathan Djuwandi,

Hope this will be helpful please check the same

https://marketplace.mendix.com/link/component/114337

answered