Type a word from the keyboard and store each letter into a series of multiple input text boxes

后端 未结 2 609
夕颜
夕颜 2021-01-22 03:47

I would like to present to the user several input text box that allows them to type a string of letters or characters that stores one letter into each box in a \'sp

2条回答
  •  深忆病人
    2021-01-22 04:37

    As @Mr.Alien said, setting MaxLength property will safeguard the text box in having more than 1 character of text. Additionally, You should select the text in the text box while it is getting a focus. It will simplify the process if user starts from the first text box again.

    $("input").keyup(function() {
    
          var input_flds = $(this).next("input");
          input_flds.select().focus();
    
    });
    

    DEMO It is a modified copy of @Mr.Alien demo

    Update:

    Implementing the above concept in a selected text box, [Concept: Set a class for the text boxes which you want to apply the need]

    $("input").keyup(function() {
    
        var input_flds = $(this).nextAll(".test:first");
        input_flds.select().focus();
    
    });
    
    //where .test will be your class on the selected text boxes.
    

    DEMO - 1

提交回复
热议问题