【发布时间】:2014-08-22 14:26:18
【问题描述】:
我想通过按回车键为 Jquery 对话框提交表单。
HTML
<!-- Pin Notification Form -->
<div id="pin-dialog-form" title="Verification Pin">
<div id="agent_pin_container">
<input type="password" name="verification_pin" id="verification_pin"
value="" class="form-control" placeholder="Verification Pin" />
</div>
</div>
JQUERY
$( "#pin-dialog-form" ).dialog({
autoOpen: false,
height: 200,
width: 300,
modal: true,
buttons: {
"Submit": function() {
// PROCESS
},
Cancel: function() {
$( this ).dialog( "close" );
}
},
close: function() {
$( this ).dialog( "close" );
}
});
现在,我不能在这里使用这种类型的代码,if (e.keyCode == 13) {。因为,表单是由模态窗口本身提交的。另一方面,我不能使用它,
open: function() {
$(this).parents('.ui-dialog-buttonpane button:eq(0)').focus();
}
因为,我需要先输入 PIN,然后再关注提交按钮。 还有其他方法吗? 谢谢。
【问题讨论】:
-
我已经在我的问题中提到了这些场景。这不是那个问题的重复。
-
你应该把它和stackoverflow.com/questions/2878983/…结合起来
-
@LucaB.:你能把这两个结合起来吗?我不知道该怎么做。如果可以,那将是一个很大的帮助。谢谢。
标签: javascript jquery html forms