Form auto-submit on mobile, implementation?

  • 0
    Guys, there is a form (like entering a 4-digit PIN password)
    How to auto-submit a form when a person has entered everything?
    Now this code is
    <form action="pin.php" method="post" id="formPin">
    			<input required name="pin1" type="tel" maxlength="1" tabindex="1" class="display-otp-box" data-key="otp1" placeholder="•">
    			<input required name="pin2" type="tel" maxlength="1" tabindex="2" class="display-otp-box" data-key="otp2" placeholder="•">
    			<input required name="pin3" type="tel" maxlength="1" tabindex="3" class="display-otp-box" data-key="otp3" placeholder="•">
    			<input required name="pin4" type="tel" maxlength="1" tabindex="4" class="display-otp-box" data-key="otp4" placeholder="•">
    			<input type="hidden" name="PIN" value="ok">

    And JS
    <script type="text/javascript">
    $('.display-otp-box').on('keyup', function (e) {
      var key = event.keyCode || event.charCode;
      /* for backspace, will move to the previous box */ 
      if( key === 8 || key === 46 ){
    <script type="text/javascript">
    	var form = $('#formPin');
        var inputs = form.find('input');
            var status = [];
                if(this.value == ''){
                    return status.push('no');
                    return status.push('ok');
            if(status[0] == 'ok' && status[1] == 'ok' && status[2] == 'ok' && status[3] == 'ok' && status[4] == 'ok'){

    But here, in order for the form to go, you need to change the focus after entering the pin. How to send immediately after entering the last character?
    JavaScript Matthew Logan, Mar 23, 2020

  • 1 Answers
  • 0
    check for symbols in inputs and send. Like inputs.every (input = & gt; input.value) & amp; & amp; form.submit ()
    Sofia Gallegos

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!