I have two datepickers:
$(".From").datepicker({
dateFormat: 'dd/mm/yy',
numberOfMonths: 1,
autoclose: true,
onClose: function(selectedDate) {
$(".To").datepicker("option", "minDate", selectedDate);
}});
$(".To").datepicker({
dateFormat: 'dd/mm/yy',
numberOfMonths: 1,
autoclose: true,
onClose: function(selectedDate) {
$(".From").datepicker("option", "maxDate", selectedDate);
}});
View:
@Html.TextBoxFor(model => model.From, new { @class = "form-control From" })
@Html.TextBoxFor(model => model.To, new { @class = "form-control To" })
Model:
[Display(Name = "From")]
public string From { get; set; }
[Display(Name = "To")]
public string To { get; set};
When the user manually enters the date, it fails.
Is there a way to allow users to enter the date and validate it?
option 1: Should I use regex?