Focus when enter keypress
heya !!!
i need one easy help
i trying to move focus to next field when enter keypress , but not working , this is my jqueryCode and HTML
this is my HTML
- <table border="0" width="29%">
- <tr>
- <td align="right"> Conta D</td>
- <td> <input type="text" name="contad" id="contad"></td>
- </tr>
- <tr>
- <td align="right"> Conta C</td>
- <td> <input type="text" name="contac" id="contac"></td>
- </tr>
- <tr>
- <td align="right"> DOC</td>
- <td> <input type="text" name="doc" id="doc"></td>
- </tr>
- <tr>
- <td align="right"> Valor </td>
- <td> <input type="text" name="valor" id="valor"></td>
- </tr>
- <tr>
- <td align="right"> HP</td>
- <td> <input type="text" name="hp" id="hp"></td>
- </tr>
- <tr>
- <td align="right"> HP Var</td>
- <td> <textarea cols="30" id="hpvar" name="hpvar" rows="4"></textarea></td>
- </tr>
- </table>
jquery
- $("table").find('#contad, #contac, #doc, #valor, #hp, #hpvar').keypress(function(e){
- var field = $(this).next('#contad, #contac, #doc, #valor, #hp, #hpvar');
- var key = e.keyCode ? e.keyCode : e.which;
- if(key == 13)
- {
- field.focus();
- return false;
- }
- });