0

I want to clear the check box and text box that reside on my form by the click of the button. I was able to clear the Text boxes, but check box is not clearing up. Below is my entire code.

Code to clear the check boxes and Text boxes:

<script src="Scripts/jquery-3.1.0.min.js" type="text/javascript"></script>
 <script type="text/javascript">
    $(document).ready(function () {
        $("#btnReset").click(function () {

            $("input[type=checkbox]").removeAttr('checked');
            $("input[type=text]").val("");
            $("textarea").val("");

        });
    });

I also tried putting

 $('.chkPool').each(function () { this.checked = false; });

instead of

$("input[type=checkbox]").removeAttr('checked');

both the above lines does not work.

The reset button that is clicked to clear text boxes and checkboxes:

<input type="button" id="btnReset" value="Clear Fields" />

The check box that I am trying to clear, but is not working is below:

 <asp:CheckBox ID="chkPool" runat="server" Text="Pool" />

any help will be appreciated.

Anjali
  • 2,540
  • 7
  • 37
  • 77
  • What is the actual client-side HTML for that check-box? JavaScript isn't particularly concerned with ASP.NET's server-side code. – David Apr 05 '17 at 18:33
  • The client side HTMl is above – Anjali Apr 05 '17 at 18:45
  • If all you have in your form is a checkbox and input then you could just change the reset button from type "button" to type "reset" and will reset form with no jQuery needed. – FD3 Apr 05 '17 at 18:47
  • @Anjali: Then the problem is that your ASP.NET server-side code isn't running *at all*. There's some problem with your setup or server configuration, which has nothing to do with the code or the content of the page. You're going to need to fix that before you can do *anything*, because server-side ASP.NET elements don't mean anything to the web browser. – David Apr 05 '17 at 18:49
  • I just used button type reset and that resolved the issue. – Anjali Apr 05 '17 at 21:40

0 Answers0