Doubt Tag Form

2

I have two form tags on a page to validate some fields that appear in modal, the first form , is just to search in grid . The% open% modal, and the remove filter function work perfectly.

However, when opening the modal, the button that sends the data does not work, it just closes the modal. And if I put it (the button) inside the buton tag, it (the form ) gives error as if it had not filled in.

<div class="modal fade" id="myModal" role="dialog">
  <div class="modal-dialog">
    <!-- Modal content-->
    <div class="row">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <div id="contact-form" class="panel panel-default">
            <div style="text-align: center;" class="panel-heading">
              <p class="panel-title">
                <asp:Label ID="Label78" runat="server" Font-Size="Large" Text="Agendar Avaliação Física"></asp:Label>
              </p>
            </div>

            <form id="form">
              <div class="row">
                <div class="modal-body">
                  <div class="col-md-2">
                    <asp:Label ID="Label18" runat="server" Text="Hora"></asp:Label>
                  </div>
                  <div class="col-md-3">
                    <div class="input-group">
                      <asp:TextBox ID="txtHora" runat="server" class="form-control" required="required" onblur="Verifica_Hora(this);"></asp:TextBox>
                      <span class="input-group-addon danger"><span class="glyphicon glyphicon-asterisk"></span></span>
                    </div>
                  </div>
                  <div class="col-md-1">
                    <asp:Label ID="Label250" runat="server" Text="Data"></asp:Label>
                  </div>
                  <div class="col-md-4">
                    <div class="input-group">
                      <asp:TextBox ID="txtData" runat="server" class="form-control" onblur="limparDataInvalida(this);" required="required"></asp:TextBox>
                      <span class="input-group-addon danger"><span class="glyphicon glyphicon-asterisk"></span></span>
                    </div>
                  </div>
                  <div class="col-md-2">
                    <asp:Label ID="Label19" runat="server" Text="Observação"></asp:Label>
                  </div>
                  <div class="col-md-9">
                    <textarea id="txtObeservacao" cols="20" rows="2" runat="server" class="form-control" style="resize: none"></textarea>
                  </div>
                </div>
              </div>
            </form>
            <div class="modal-footer">
              <asp:Button ID="btnGravar" runat="server" CssClass="btn btn-success btn-block" Text="Gravar" OnClick="btnGravar_Click" />
            </div>
          </div>
        </div>
      </div>
      <br />
    </div>
  </div>
</div>

It should save, in the code I save the data in the bank or change, how can I make it work?

    
asked by anonymous 25.04.2018 / 21:46

1 answer

3

I was able to solve this by placing the button on the button, activate the required, and when I finish the operation, or close the modal, I put the required off, worked perfectly, I did not need to create another form tag, let alone create another function, I thought of creating other tagform to validate each form, but it was getting impractical as it did not work. When opening the modal:

 function openModal() {
            $('#myModal').modal('show');
            ($("#<%=txtHora.ClientID %>").prop('required', true));
            ($("#<%=txtData.ClientID %>").prop('required', true));
            ($("#<%=txtassunto.ClientID %>").prop('required', true));
        }

And when you closed the modal, or the operation was completed:

  function Campos() {
            ($("#<%=txtHora.ClientID %>").prop('required', false));
            ($("#<%=txtData.ClientID %>").prop('required', false));
            ($("#<%=txtassunto.ClientID %>").prop('required', false));
         }
    
27.04.2018 / 14:23