I'm using the data-val-required to replace the standard message for required field and get a french custom message displayed and it works well. I'm also using the data-val-date attribute to do the same when the date entered in my field is invalid but it doesn't work. Any idea?
<input id="datDebt" type="text" class="form-control datepicker valid" data-val="true" data-val-required="BD-Le champ Du est obligatoire." data_val_date="BD-Le format du champ Du doit être AAAA-MM-JJ." name="Client.DatDebutClint" value="" aria-autocomplete="none" placeholder="AAAA-MM-JJ" style="min-width: 7em;" maxlength="10" aria-describedby="datDebt-error" aria-invalid="false">
[DisplayName("Du")]
[DataType(DataType.DateTime)]
public DateTime? DatDebutClint { get; set; } = null;
I've included the jquery.validation script, added the datatype attribute to my model property
You haven’t implement the validation logic, yes you can directly modify the jquery and get the client validation through a custom js file. However in my test, the model format validation still remains, and the date will not get displayed correctly after created.
The default datetype validation works like a calendar, to meet your need it is recommended to implement a custom client validation. Here is my code sample.
Test