0
How can I clean the modal data, sometimes the user enters the data but not saved, and if he opens the modal again, the data is there, I would like to clean this data, how should I proceed? Sometimes it also happens to save, and when clicking to add the new data, the old data that was saved is still in modal. Follow the code of my modal:
<div class="modal fade" id="myModal" role="dialog">
  <div class="modal-dialog">
    <div class="grid-10">
      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">×</button>
          <h4 class="modal-title">Cadastrar Banco</h4>
        </div>
        <div class="modal-body">
          <br />
          <asp:Label ID="Label2" runat="server" Text="Nome"></asp:Label>
          <asp:TextBox ID="txtNome" runat="server" CssClass="radiusInput"></asp:TextBox>
          <br />
          <br />
          <br />
          <asp:Label ID="Label1" runat="server" Text="Número"></asp:Label>
          <asp:TextBox ID="txtNumero" runat="server"></asp:TextBox>
          <br />
          <br />
          <br />
        </div>
        <div class="modal-footer">
          <asp:Button ID="Button1" runat="server" Text="Gravar" CssClass="radiusInput" OnClick="Button1_Click1" />
        </div>
      </div>
    </div>
  </div>
</div>
It cleans the data, but even clears up what is written on the button, I would like it to clean only the textbox.
– Mariana
@marianac_costa I edited the answer by selecting only the
inputswhich are of the text type. See if it suits you now. If you have a specific field, you can use some type of selector, such as id or class. Something like$('#txtNome').val(' ').– Randrade
It worked, thank you.
– Mariana