0
I’m using Partial View for registration of Pessoa, that is, in my View have two RadioButton: Pessoa Fisica and Pessoa Juridica, when selecting the Radio Button I’ll tell you what 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 containing the necessary inputs,
Everything is working so far, BUT, when I give Submit, it does not validate my inputs, which put the requirements in my Model
In my View Create I left the class to receive the inputs and the 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>
}
my contents of the archives .cshtml will press the div , segue meuModel: `
[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; }
summarizing, it does not validate my inputs and goes to Controller