I have a Kendo UI date picker extension for MVC4. I would reply this kendo demo, where there are 2 datepicker and if i put in the "startDate" a date greather than the "EndDate", kendo validator must show the error.
The validation of kendo don't show the message of the value put in the end date greather than of the value put in the start date,
This the razor code of 2 field datepicker:
<div class="row">
<div class="col-md-4">
@(Html.Kendo().DatePickerFor(m => m.StartDate)
.Format("dd/MM/yyyy")
)
</div>
<div name="DataPeriodo" class="col-md-8">
@(Html.Kendo().DatePickerFor(m => m.EndDate)
.Format("dd/MM/yyyy")
.HtmlAttributes(new { data_greaterdate_field = "StartDate", data_greaterdate_msg = "Retire date should be after Hire date" })
)
</div>
</div>
This is the test for the "greatherThan" validation:
$(document).ready(function () {
var container = $('form');
kendo.init(container);
container.kendoValidator({
rules: {
greaterdate: function (input) {
if (input.is("[data-greaterdate-msg]") && input.data("kendoDatePicker").value() != "") {
var date = kendo.parseDate(input.data("kendoDatePicker").value()),
otherDate = kendo.parseDate($("#StartDate").data("kendoDatePicker").value());
//The test for understand if the code work.
alert(otherDate == null || otherDate.getTime() < date.getTime());
return otherDate == null || otherDate.getTime() < date.getTime();
}
return true;
}
}
});
});
I try to create a fiddle but the click button don't fire the validation while in my asp.net mvc solution work and show the alert of test.
The problem is that the test correctly shows the alert with the test (true or false) but differently from the kendo's demo don't shows the with the error defined in the attribute "data-greaterdate-msg".
UPDATE
I don't find any solution. I opted for FoolProof library and i validate only server-side.