0
I have a form, that the button that makes his Submit, stays outside the tag
<form>
.
then I send it via Script.
The problem is he’s not validating the Form
, before sending.
I always only used the call of the scripts, which form already validated.
but this with Ubmit inside the tag
form
.
The Submit Script is this:
<script src="~/Scripts/jquery.validate.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.js"></script>
<script type="text/javascript">
function Enviar() {
document.forms["frmCliente"].submit();
}
</script>
<form id="fmrCliente" action="/Gerencial/ClienteGerencial/Create">
<label>Razão Social</label>
<input class="form-control-sm text-box single-line" data-val="true" data-val-maxlength="máximo de Razão Social caracteres" data-val-maxlength-max="200" data-val-required="O campo Razão Social é obrigatório." id="Cliente_RazaoSocial" name="Cliente.RazaoSocial" value="">
</form>
<button class="btn botoes" type="submit" onclick="Enviar();" id="submeter" name="submeter">
Gravar
</button>
Does anyone know how to validate it before sending it?
I didn’t put it there, but I’m making the call from Jquery.js
I couldn’t... even filling all the fields, the form doesn’t make the Ubmit, I put the
debugger
and I saw, that the envendo click ta funfando... only the form is always invalid, even with all fields filled– Rafael Passos
if you are not sending it is because there are errors. use this code to see what is wrong:
var validacao = $("form").validate();
var erros = validacao.errors();
can inspect errors or make an Alert– Ricardo Pontual