[英]Disabling the Submit button After one click using tagID
單擊(僅在DB中輸入數據一次)提交按鈕后,該頁面應重定向到下一頁,而如果用戶兩次單擊提交按鈕,則數據在Db中輸入兩次。
禁用了提交按鈕,避免了多個條目仍然存在的問題
<netui:form action="login" method="post" onSubmit="return checkForm();" tagId="ckeckLogin">
<table style="width: 100%;">
<tr>
<td style="width: 45%;">
<div>
<table style="width:100%;" border="0">
<tr>
</tr>
<% if (SiteInfo.isLocalhost(request)) { %>
<tr style="vertical-align:top;">
<td style="width:3%; white-space:nowrap;text-align: right;" class="right-align" id="loginForm.label.id"><i18n:getMessage messageName="portlets.label.pagecode.id"/>:</td>
<td class="left-align"><netui:textBox tagId="pageLookup_id" dataSource="actionForm.id" size="8" maxlength="25" style="text-transform: uppercase;"/><br/></td>
</tr>
<tr>
<td class="center-align" colspan="2">
<netui:button type="reset" onClick="document.forms[getNetuiTagName('clearFrom', this)].submit();"><i18n:getMessage messageName="portlets.button.clear"/></netui:button>
<!-- Submit button goes here ---> <netui:button type="submit"><i18n:getMessage messageName="portlets.button.login"/></netui:button>
</td>
</tr>
</table>
</netui:form>
JavaScript:
function checkForm()
{
var validateErrorReason = '';
// reset the validation label errors
document.getElementById('loginForm.label.id').className = '';
var errorData = document.getElementById('submitResetRequestForm.errorData');
if(!(validateErrorReason == '')) {
errorData.innerHTML = '<i18n:getMessage messageName="error.form.highlight" />';
return (false);
}
//To Disable Submit button
document.getElementById('ckeckLogin').disabled = true;
}
一鍵單擊后,提交按鈕應禁用
<input type="submit" id="subBtn" value="Send" /> <button onclick="document.getElementById('subBtn').disabled = true;">True</button> <button onclick="document.getElementById('subBtn').disabled = false;">False</button>
您必須為提交按鈕分配一個ID,才能從getElementById('id')獲取它並禁用它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.