In model I am using below code:
[Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(InformationResources))]
[DataType(DataType.Date, ErrorMessageResourceName = "DateInvalid", ErrorMessageResourceType = typeof(InformationResources))]
[DisplayFormat(DataFormatString = "{0:yyyy/MM/dd}", ApplyFormatInEditMode = true)]
[FutureDate(ErrorMessageResourceName = "DateInPast", ErrorMessageResourceType = typeof(InformationResources))]
public DateTime? FirstTrade { get; set; }
In view I am using below code:
<div>
@Html.TextBoxFor(m => m.FirstTrade, new { @Value = Convert.ToDateTime(Model.FirstTrade).ToString("yyyy/MM/dd"),@class = "form-control input-sm", @type = "date", @max = DateTime.Now.AddYears(1).ToString("yyyy-MM-dd") })
@Html.ValidationMessageFor(model => model.FirstTrade)
</div>
Now if I select data from date time picker in "yyyy/MM/dd" format then I am getting error message as "The field FirstTrade must be a date". One more thing that I am using en-Au locale. Please let me know how to remove the error message If i choose date in "yyyy/MM/dd" format.
Thanks in advance.