0
How I could submit a form according to the active Bootstrap tab, ignoring the validation of the unselected tab?
Example: I have an "A" tab with an "A1" form and some fields with required
, and a "B" tab with a "B1" form with other fields required
.
When selecting the "B" tab and submitting the form "B1", do not validate the fields of the form "A1", only of the form "B1", sending the data of the respective form.
I tried a few ways though, either it does not send any form, or it is validating the form not active.
Follows code:
<div class="tab-content">
<div role='tabpanel' class='tab-pane active' id='produto'>
<form action="form/acao_solicitacao.php?form=cad_produto" name="cad_produto" method="post" enctype="multipart/form-data">
<input type="hidden" name="id_solicitacao" value="<?php proximoIdSol(); ?>">
<div class="form-group col-md-12">
<label for="solicitante">Solicitante</label>
<input type="text" class="form-control" name="solicitante" id="solicitante" readonly="true" value="<?php echo $_SESSION['nome_usuario'] ?>">
</div>
<div class="form-group col-md-6">
<label for="setor">Centro de Custo</label>
<input type="text" class="form-control" name="setor" id="setor" required placeholder="Setor do solicitante">
</div>
<div class="form-group col-md-6">
<label for="filial">Filial</label>
<select class="form-control" name="filial" id="filial" required>
<option>Selecione a filial</option>
<option value="Componentes">Componentes</option>
<option value="Metais">Metais</option>
<option value="Sistemas">Sistemas</option>
</select>
</div>
<div class="form-group col-md-12">
<label for="descricao_prod">Descrição</label>
<textarea class="form-control" name="descricao_prod" id="descricao_prod" required placeholder="Descrição do produto"></textarea>
</div>
<div class="form-group col-md-6">
<label for="tipo_prod">Tipo</label>
<input type="text" class="form-control" name="tipo_prod" id="tipo_prod" placeholder="Tipo do Produto">
</div>
<div class="form-group col-md-6">
<label for="finalidade_prod">Finalidade</label>
<input type="text" class="form-control" name="finalidade_prod" id="finalidade_prod" placeholder="Finalidade do Produto">
</div>
<div class="row"></div>
<div class="form-group col-md-6">
<label for="armazem">Armazém</label>
<input type="text" class="form-control" name="armazem" id="armazem" placeholder="Armazém">
</div>
<div class="form-group col-md-6">
<label for="ncm">NCM</label>
<input type="number" class="form-control" name="ncm" id="ncm" required maxlength="8" placeholder="NCM">
</div>
<div class="form-group col-md-3">
<label for="mov_estoque">Movimenta estoque?</label>
<label class="radio-inline"><input type="radio" id="mov_estoqueS" name="mov_estoque" value="S">Sim</label>
<label class="radio-inline"><input type="radio" id="mov_estoqueN" name="mov_estoque" value="N">Não</label>
</div>
</form>
</div>
<div role='tabpanel' class='tab-pane' id='fornecedor'>
<form action="form/acao_solicitacao.php?form=cad_fornecedor" name="cad_fornecedor" method="post" enctype="multipart/form-data">
<input type="hidden" name="id_solicitacao" value="<?php proximoIdSol(); ?>">
<div class="form-group col-md-12">
<label for="solicitante">Solicitante</label>
<input type="text" class="form-control" name="solicitante" id="solicitante" readonly="true" value="<?php echo $_SESSION['nome_usuario'] ?>">
</div>
<div class="form-group col-md-6">
<label for="setor">Centro de Custo</label>
<input type="text" class="form-control" name="setor" id="setor" required placeholder="Setor do solicitante">
</div>
<div class="form-group col-md-6">
<label for="filial">Filial</label>
<select class="form-control" name="filial" id="filial" required>
<option>Selecione a filial</option>
<option value="Componentes">Componentes</option>
<option value="Metais">Metais</option>
<option value="Sistemas">Sistemas</option>
</select>
</div>
<div class="form-group col-md-6">
<label for="razao_social_forn">Razão Social</label>
<input type="text" class="form-control" name="razao_social_forn" id="razao_social_forn" required placeholder="Razão Social do Fornecedor">
</div>
<div class="form-group col-md-6">
<label for="nome_fantasia_forn">Nome Fantasia</label>
<input type="text" class="form-control" name="nome_fantasia_forn" id="nome_fantasia_forn" required placeholder="Nome Fantasia do Fornecedor">
</div>
<div class="form-group col-md-6">
<label for="cnpj_forn">CNPJ</label>
<input type="text" class="form-control" name="cnpj_forn" id="cnpj_forn" required placeholder="CNPJ do Fornecedor">
</div>
<div class="form-group col-md-6">
<label for="ie_forn">Inscrição Estadual</label>
<input type="text" class="form-control" name="ie_forn" id="ie_forn" required placeholder="Inscrição Estadual do Fornecedor">
</div>
<div class="form-group col-md-4">
<label for="tipo_forn">Tipo</label>
<input type="text" class="form-control" name="tipo_forn" id="tipo_forn" required placeholder="Tipo do Fornecedor">
</div>
<div class='row'></div>
<div class="form-group col-md-8">
<label for="endereco_forn">Endereço</label>
<input type="text" class="form-control" name="endereco_forn" id="endereco_forn" required placeholder="Endereço do Fornecedor">
</div>
<div class="form-group col-md-4">
<label for="bairro_forn">Bairro</label>
<input type="text" class="form-control" name="bairro_forn" id="bairro_forn" required placeholder="Bairro do Fornecedor">
</div>
<div class="form-group col-md-4">
<label for="cidade_forn">Cidade</label>
<input type="text" class="form-control" name="cidade_forn" id="cidade_forn" required placeholder="Cidade do Fornecedor">
</div>
<div class="form-group col-md-4">
<label for="estado_forn">Estado</label>
<input type="text" class="form-control" name="estado_forn" id="estado_forn" required placeholder="Estado do Fornecedor">
</div>
<div class="form-group col-md-4">
<label for="pais_forn">País</label>
<input type="text" class="form-control" name="pais_forn" id="pais_forn" required placeholder="País do Fornecedor">
</div>
<div class="form-group col-md-4">
<label for="cep_forn">CEP</label>
<input type="text" class="form-control" name="cep_forn" id="cep_forn" required placeholder="CEP do Fornecedor">
</div>
<div class="form-group col-md-4">
<label for="tel_forn">Telefone</label>
<input type="text" class="form-control" name="tel_forn" id="tel_forn" required placeholder="Telefone do Fornecedor">
</div>
<div class="form-group col-md-4">
<label for="email_forn">E-mail</label>
<input type="email" class="form-control" name="email_forn" id="email_forn" required placeholder="E-mail do Fornecedor">
</div>
</form>
</div>
</div>
<div class="modal-footer col-md-12">
<button type="submit" class="btn btn-primary">Salvar</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
</div>
Post what you already have Thiago. What is the possibility of making 2 form ?
– Ricardo Mota
Lock the Ubmit button ?
– Ricardo Mota
Ready...button also added to the above code.
– Thiago Alessandro