Date Input returning Time along with date

Asked

Viewed 52 times

-1

Example:
inserir a descrição da imagem aqui

I’d like you to return only to Data, but I don’t know what to do!
My code:

[Display(Name = "Data de Nascimento")]
    //[DataType(DataType.Date)]
    //[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}")]
    [Required(AllowEmptyStrings = false, ErrorMessage = "Por favor, informe sua data de nascimento.")]
    public System.DateTime dtNascimento { get; set; }  

I use a Jquery to make the input beautiful and such... Code:

$("#dtNascimentoFuncMeusDados").removeAttr("data-val-date");
$('#dtNascimentoFuncMeusDados').datepicker({
    weekStart: 0,
    maxViewMode: 2,
    language: "pt-BR",
    multidate: false,
    autoclose: true,
    todayHighlight: true
});

1 answer

0

Move your property to string in his ViewModel.

public string dtNascimento { get; set; }

If she’s the type Datetime it will always request date and time. In the model it can and should be of the type Datetime and when to convert from ViewModel for Model (entity) you make the necessary validations.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.