Input field focus shift

Input field focus shift

  

Hi,

    I am working on Table Records, where after entering the max length of the input text field of a record. The focus of the input field should be shifted to next input field of the record. 

Please can anyone help us in finding the solution for this issue.

Thank You.

talluri chandra wrote:

Hi,

    I am working on Table Records, where after entering the max length of the input text field of a record. The focus of the input field should be shifted to next input field of the record. 

Please can anyone help us in finding the solution for this issue.

Thank You.

Hi Talluri,

Solution 1.
Use the OnChange Screen action to check the number of characters in the input and set the focus in the next field if reached maximum. 

Solution 2.
Use JavaScript to capture the key press, count the number of characters and change to the next input.
(ex.: https://stackoverflow.com/questions/15595652/focus-next-input-once-reaching-maxlength-value)

Hope this helps.

Cheers.

$('input[type=text]').keydown(function(e){


    // check the current textlength and check the maxLength of the input

    var currentLength = $(this).val().length;

    var maxLength = $(this).attr("maxLength");

    console.log(maxLength);

    console.log(currentLength);


    if (currentLength >= maxLength){

    // we want to allow the pressing of delete and backspace to allow the user to remove text

if (e.which != 8 && e.which != 46){

        // this will set the focus to the next text input and simulate the keydown event

        $(this).next('input[type=text]').keydown().focus();

          }

    }

});