Order entry form contains product code and quantity columns in multiple rows and delete button
(-) in end of every row. It contains also add button in first column and after form.
Pressing enter key should set focus to next text or numeric input field (product code or quantity), skipping buttons.
I tried code below is used but enter key is ignored.
Chrome debugger shows that line $(this).next('input').focus()
is executed but
focus() call does not have any effect.
jquery, jquery-mobile, ASP.NET MVC4 are used
<!DOCTYPE html>
<html>
<head>
<script src=/Scripts/jquery/jquery-1.9.1.js></script>
</head>
<body>
<div data-role=page data-theme=a>
<div data-role=content>
<script>
$(function () {
$('#inputform').on('keydown', 'input', function (event) {
if (event.which == 13) {
$(this).next('input').focus();
event.preventDefault();
}
});
});
</script>
<form id='inputform' method=post
action =/Detail/SaveFullDocument?_entity=DokG&_id=0>
<fieldset>
<div class='form-field' >
<label class='form-label' for='Tasudok'>Order number</label>
<input class='ui-widget-content ui-corner-all form-fullwidth' id='Tasudok' name='Tasudok' value='' maxlength='25' /></div>
<input type=hidden name=_rows />
<table id=tableId>
<tr>
<th>Product code</th>
<th>Quantity</th>
<td>
<input type=button value=+ onclick=addRow('tableId') /></td>
</tr>
<tr>
<td>
<input type=text name=Toode /></td>
<td>
<input type=number name=Kogus /></td>
<td>
<input type=button value=- onclick=deleteRow(this) /></td>
</tr>
</table>
<input type=button value=+ onclick=addRow('tableId') />
<input type=submit value='Save order' />
</form>
</div>
</div>
</body>
</html>