How do ENTER jump from the field instead of sending?

Asked

Viewed 548 times

-1

Command to save information to the bank:

<button id="btnslv" type="submit" class="btn btn-success btn-block" name="btnslv" value="0">SALVAR</button>

My Form:

<form class="" id="form" action="<?php echo $_SERVER['PHP_SELF'] ?>" name="cadastro" method="post" enctype="multipart/form-data">

I tried to change "Submit" for "button" and it worked, but it does not record the inforamções to the bank.

I’ve also tried using "onClick = "Document.cadastro.Submit()"", but it didn’t work either.

Do you have any idea how I might proceed?

1 answer

1

Hello, all right? I found an answer that can help you! If you want to see the original answer Click here

   $("input, select", "form") // busca input e select no form
    .keypress(function(e){ // evento ao presionar uma tecla válida keypress
       
       var k = e.which || e.keyCode; // pega o código do evento
       
       if(k == 13){ // se for ENTER
          e.preventDefault(); // cancela o submit
          $(this)
          .closest('tr') // seleciona a linha atual
          .next() // seleciona a próxima linha
          .find('input, select') // busca input ou select
          .first() // seleciona o primeiro que encontrar
          .focus(); // foca no elemento
       }
    
    });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form id="documento" name="documento" method="post" action="inclusao.php" onsubmit="return validaCampo(); return false;">
    <table width="100%" border="0">
      <tr>
        <th colspan="2" align="center" valign="top">
          <h3>Cadastro de Documento </h3>
        </th>
      </tr>
      <tr>
        <td width="138">CPF/CNPJ:</td>
        <td width="835"><input name="CNPJ" type="text" id="CNPJ" size="20" maxlength="14" />
          <span class="style1">*</span> <span class="style3">somente n&uacute;meros</span></td>
      </tr>
      <tr>
        <td>Data Recebimento:</td>
        <td>
          <input type="text" name="DataRec" id="DataRec" size="10" maxlength="10" /> <span class="style1">*</span>
        </td>
      </tr>
      <tr>
        <td>Tipo de Documento:</td>
        <td>
          <select name="TipDoc" id="TipDoc">
            <option value="NF">NF</option>
            <option value="CTO">CTO</option>
            <option value="MTO">MTO</option>
            <option value="OUTROS">OUTROS</option>
          </select> <span class="style1">*</span></td>
      </tr>
      <tr>
        <td>N&uacute;mero do Documento.:</td>
        <td><input type="tel" name="NumNFC" id="NumNFC" size="9" maxlength="9" /> <span class="style1">*</span></td>

      </tr>
      <tr>
        <td>Quantidade (Volume)</td>
        <td><input name="QTDVol" type="tel" id="QTDVol" size="4" maxlength="4" /> <span class="style1">*</span> <span class="style3">em litros</span></td>
      </tr>
      <tr>
        <td>Processo</td>
        <td><input name="proces" type="text" id="proces" size="14" maxlength="14" /> <span class="style1">*</span></td>
      </tr>
      <tr>
        <td>Local de Entrega:</td>
        <td><input name="CDRDES" type="text" id="CDRDES" maxlength="15" size="15" />
          <span class="style1">*</span></td>
      </tr>
      <tr>
        <td>Fornecedor:</td>
        <td> <input name="FORNEC" type="text" id="FORNEC" maxlength="20" size="20" /> <span class="style1">*</span>
        </td>
      </tr>
      <tr>
        <td colspan="2">
          <p>
            <input name="cadastrar" type="submit" id="cadastrar" value="Confirmar" />
            <br />
            <input name="limpar" type="reset" id="limpar" value="Limpar Campos preenchidos!" />
            <br />
            <span class="style1">* Campos com * s&atilde;o obrigat&oacute;rios!          </span></p>
          <p>&nbsp; </p>
        </td>
      </tr>
    </table>
  </form>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.