1
How to make in an HTML form it changes from one field to another later when pressing the key Enter? (It naturally changes by pressing TAB).
There is already a topic related to this subject, however, where to put the code in Javascript? It is in <body>
or in the <head>
? He doesn’t have to reference the <form>
containing the Textfields?
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<body>
<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ú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ú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ão obrigatórios! </span></p>
<p> </p>
</td>
</tr>
</table>
</form>
</body>
Depending on the application, I would discourage you from doing this, as it is altering the application’s natural behavior and this can be awkward for the user
– Woss
Hello @dvd, the link to this other question does not use a '<table>'. Use the '<div>'. Putting the same code in the '<body>' of this code here, Enter does not work to change to the next '<input>'.
– Marvin