I'm using Partial View
to Pessoa
record, that is, in my View
have two RadioButton
: Pessoa Fisica
and Pessoa Juridica
, to select the Radio Button
I do the following ajax
:
$(function () {
$(".radioPessoa").change(function (event) {
var opcao = $(this).val();
$.ajax({
url: '@Url.Action("OpcaoPessoa", "Cadastro")',
data: { opcao: opcao },
type: 'GET',
success: function (data) {
$(".loadpartial").html(data);
}
});
});
});
There, I have these two files .cshtml
which contains the required inputs,
Everything is working so far, AND when I give submit, it does not validate my inputs, I put the requirements in my Model
%
In my View
Create
I left the class to receive inputs
and submit
:
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<div class="loadpartial">
</div>
<div class="col-xs-12 col-md-12 semPadding marginCimaBaixo clearfix">
<input type="submit" value="Salvar" class="btn btn-success" />
</div>
}
Then my content from files .cshtml
will load into div , segue meu
Model: '
[Required(ErrorMessage = "Campo CPF deve ser preenchido")]
[RegularExpression(@"[0-9.-]{14}", ErrorMessage = "Por favor, preencha o CPF apenas com números.")]
public string CPF { get; set; }
In short, it does not validate my inputs and goes to Controller