0
I have a form where the data placed on it is recorded in the db by a jQuery, but we radiobutton cannot save the item I select.
Below a part of my form. On the radiobutton Sexo_Segurado that I have the problem.
<div class="col-sm-4 col-sm-offset-2">
    <div class="form-group">
        @Html.LabelFor(model => model.CPF_Segurado, htmlAttributes: new { 
            @class = "Myclass" 
        })
        @Html.EditorFor(model => model.CPF_Segurado, new { htmlAttributes = new { 
            @id = "CPF_Segurado", 
            @type = "text", 
            @placeholder = "Ex: 142.035.046-43", 
            @class = "form-control" 
        } })
        @Html.ValidationMessageFor(model => model.CPF_Segurado, "", new { 
            @class = "text-danger" 
        })
    </div>
</div>
<div class="col-sm-4">
    <div class="form-group">
        @Html.LabelFor(model => model.Data_Nasc_Segurado, htmlAttributes: new { 
            @class = "Myclass" 
        })
        @Html.EditorFor(model => model.Data_Nasc_Segurado, new { htmlAttributes = new { 
            @type = "date", 
            @placeholder = "01/01/2019", 
            @class = "form-control" 
        } })
        @Html.ValidationMessageFor(model => model.Data_Nasc_Segurado, "", new { 
            @class = "text-danger" 
        })
    </div>
</div>
<div class="col-sm-4 col-sm-offset-2">
    <div class="form-group">
        @Html.LabelFor(model => model.Sexo_Segurado, htmlAttributes: new { 
            @class = "Myclass"
         })
        <br />
        @Html.RadioButtonFor(model => model.Sexo_Segurado,"Masculino", new {  
            name = "Masculino", 
            @value = "Masculino", 
            @id = "Sexo_Segurado",  
            @class = "with-gap" 
        })
        <label for="Masculino">Masculino</label>     
        @Html.RadioButtonFor(model => model.Sexo_Segurado, "Feminino", new {  
            name = "Feminino", 
            @value = "Feminino", 
            @id = "Sexo_Segurado", 
            @checked = "checked", 
            @class = "with-gap" 
        })
        <label for="Feminino">Feminino</label>
    </div>
</div>
Below follows my Jquery that I use to save the form data:
function SalvarCliente() {
debugger;
//Segurado
var cpf_segurado = $("#CPF_Segurado").val();
var data_nasc_segurado = $("#Data_Nasc_Segurado").val();
var sexo_segurado = $("#Sexo_Segurado").val();
var token = $('input[name="__RequestVerificationToken"]').val();
var tokenadr = $('form[action="/Cliente/Create"]inputname="__RequestVerification"]').val();
var headers = {};
var headersadr = {};
headers['__RequestVerificationToken'] = token;
headersadr['__RequestVerificationToken'] = tokenadr;
var url = "/Cliente/Create";
$.ajax({
    url: url
    , type: "POST"
    , datatype: "json"
    , headers: headersadr
    , data: {
        Id: 0,
        CPF_Segurado: cpf_segurado,
        Data_Nasc_Segurado: data_nasc_segurado,
        Sexo_Segurado: sexo_segurado,
        __RequestVerificationToken: token
     }
    , success: function (data) {
        if (data.Resultado > 0) {
        }
    }
});
						
Try it like this: $("#Sex Insured"). attr('checked')
– Victor Laio