我有BackoutClaim页面。在提交按钮上单击,我必须禁用该按钮,并且从POst方法,当响应返回时,我必须启用按钮。
在下面的代码中,按钮没有禁用。 感谢您的回复。
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript">
function TrimThatNameThenSubmit() {
var tableName = $('#tableName').val().replace(/^\s+|\s+$/g, "");
$('#tableName').val(tableName);
**$('#Submit').attr('disabled', 'disabled');**
$('form:eq(0)').submit();
}
</script>
<%
var messages = ViewData["messages"];
%>
<% using (Html.BeginForm()) { %>
<div>
<div class="Spacer"></div>
<div class="RevertCaseStateHeader" align="center">
<%= Html.TextBox("tableName", "Enter tableName to Backout Claim", new { @style = "width: 400px;" })%>
<input type="button" value="Submit" onclick="javascript:TrimThatNameThenSubmit()"/>
</div>
<div class="RevertCaseStateSummary" align="center">
<% if (messages != null)
{ %>
<%= Html.Encode(messages)%>
<% } %>
</div>
</div>
<% } %>
</asp:Content>
答案 0 :(得分:2)
您的jQuery正在选择id = Submit的按钮,该按钮不存在,请将您的按钮定义更改为:
<input id="Submit" type="button" value="Submit" onclick="javascript:TrimThatNameThenSubmit()"/>