locked
Clear Values RRS feed

  • Question

  • User-1499457942 posted

    Hi

      I have below code and i want all Controls should have blank value

    <button type="button" id="btnAdd" class="btn btn-primary" data-toggle="modal" data-target="#myAddModal">Add New</button><br /><br />

    I am trying below code but not working

    $('#myAddModal').on('hidden.bs.modal', function (e) {
    $(this).removeData();
    });

    Thanks

    Friday, August 17, 2018 8:51 AM

Answers

  • User-369506445 posted

    Try below

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    
    $('#myAddModal').on('hidden.bs.modal', function (e) {
    
    $(':input[type=text]').val('');
    
    });

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 17, 2018 1:00 PM

All replies

  • User-369506445 posted

    Hi

    You can try 

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    
    $('#myAddModal').on('hidden.bs.modal', function (e) {
    
    $(':input').val('');
    
    });

    Friday, August 17, 2018 12:21 PM
  • User-1499457942 posted

    Hi

      It is working but it is clearing the content of this also - Text=" Save Record"

    <div class="col-sm-5">
    <asp:Button ID="btnInsert" CssClass="btn btn-primary" runat="server" class="btn btn-primary" ValidationGroup="One" Text=" Save Record" OnClick="InsertData" ></asp:Button>
    </div>

    Thanks

    Friday, August 17, 2018 12:31 PM
  • User-369506445 posted

    Yes , it's clear all inputs value, you wanted do this, didn't you?

    Friday, August 17, 2018 12:46 PM
  • User-1499457942 posted

    Hi

      I want to clear only texxtboxes value not button

    Thanks

    Friday, August 17, 2018 12:51 PM
  • User-369506445 posted

    Try below

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    
    $('#myAddModal').on('hidden.bs.modal', function (e) {
    
    $(':input[type=text]').val('');
    
    });

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 17, 2018 1:00 PM