0

I have BackoutClaim page. On the Submit button click, I have to disable the button and from the POst method, when the response comes back, I have to enable button back.

In the below code, the button is not disabling. Appreciate your responses.

    <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>
1
  • I'm pretty sure the following line is useless : $('form:eq(0)').submit(); Commented Aug 15, 2012 at 16:48

1 Answer 1

2

Your jQuery is selecting the button with id=Submit which doesn't exist, change your button definition to:

<input id="Submit" type="button" value="Submit" onclick="javascript:TrimThatNameThenSubmit()"/>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.