請參閱下面的代碼以進行工作演示。將打開一個jQuery UI模式對話框,並要求用戶輸入密碼。如果submit
按鈕突出顯示,則一切正常。但是,如果輸入區域仍然突出顯示,則頁面顯示爲重新加載,並且瀏覽器中的URL更改爲example.com?confirm_password=asdfasdf#
。如何在jQuery UI對話框中的輸入區域突出顯示時停止從提交表單輸入密鑰? (示例代碼)
我懷疑這是因爲我有一個窗體嵌入對話框,但這是基於一個jQuery示例。
我該如何解決這個問題,以便在突出顯示的文本輸入框中按回車鍵相當於點擊提交?
<html>
<head>
<title>Problem Demo</title>
<link href="http://code.jquery.com/ui/1.9.0/themes/base/jquery-ui.css" rel="stylesheet" type="text/css">
<script src="http://code.jquery.com/jquery-1.7.min.js"></script>
<script src="http://code.jquery.com/ui/1.9.0/jquery-ui.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#myDialog').dialog({
autoOpen: false,
modal: true,
buttons: {
"Submit": function() {
$(this).dialog('close');
},
Cancel: function() {
$(this).dialog('close');
}
}
});
$('#openMyDialog').click(function() {
$('#myDialog').dialog('open');
});
});
</script>
</head>
<body>
<a id="openMyDialog" href="#">Open Dialog</a>
<div id="myDialog">
<p style="text-align: left;">Please enter your password.</p>
<form>
<fieldset>
<label for="confirm_password">Password</label>
<input type="password" name="confirm_password" id="confirm_password" value="" />
</fieldset>
</form>
</div>
</body>
</html>
對不起明確綁定你的形式,我的問題是不明確的。我想按回車鍵相當於點擊提交。我可以刪除