I have a field in my application in mvc asp.net c # to put start date and end date.
[Required(ErrorMessage = "A data de início é obrigatória")]
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
public DateTime DataInicio { get; set; }
However, while the user is typing the date a red message appears below the field:
The field must be a date.
I did not implement this, I do not know where it comes from. Does anyone know how to disappear with this alert?
View
@model Competências.Models.Experiencia
@Scripts.Render("~/bundles/validation")
@using (Ajax.BeginForm(new AjaxOptions
{
InsertionMode = InsertionMode.Replace,
HttpMethod = "POST"
}))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<div class="modal-body row">
<div class="col-md-7">
@Html.LabelFor(model => model.Nome)
@Html.TextBoxFor(model => model.Nome, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Nome)
</div>
<div class="col-md-5">
@Html.LabelFor(model => model.Funcao)
@Html.TextBoxFor(model => model.Funcao, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Funcao)
</div>
</div>
<div class="modal-body row">
<div class="col-md-4">
@Html.LabelFor(model => model.DataInicio)
@Html.EditorFor(model => model.DataInicio, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.DataInicio)
</div>
<div class="col-md-4">
@Html.LabelFor(model => model.DataFinal)
@Html.EditorFor(model => model.DataFinal, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.DataFinal)
</div>
</div>
<div class="modal-footer">
<input class="btn btn-primary" type="submit" value="Salvar" />
<a class="btn btn-default" onclick="FechaModal();">Cancelar</a>
</div>
}
Input generated in browser
<div class="modal-body row">
<div class="col-md-4">
<b>Data de Início</b>
<input class="text-box single-line" data-val="true" data-val-date="O campo DataInicio deve ser uma data." data-val-required="A data de início é obrigatória" id="DataInicio" name="DataInicio" type="date" value="">
<span class="field-validation-valid" data-valmsg-for="DataInicio" data-valmsg-replace="true"></span>
</div>
<div class="col-md-4">
<b>Data Final</b>
<input class="text-box single-line" data-val="true" data-val-date="O campo DataFinal deve ser uma data." data-val-required="A data de início é obrigatória" id="DataFinal" name="DataFinal" type="datetime" value="">
<span class="field-validation-valid" data-valmsg-for="DataFinal" data-valmsg-replace="true"></span>
</div>
<div class="col-md-3">
</div>
</div>