나는 검도 datetimepicker 컨트롤이 있고 사용자가 직접 콜론이 누락 된 잘못된 형식으로 입력하면 유효성 검사에서이 값을 인식하지 못하고 MVC 컨트롤러에서 models 속성의 날짜/시각.검도 DateTimePicker 형식 HHmm
내 클라이언트 유효성 검사는 21/01/2015 1230을 구문 분석 할 수 있지만 컨트롤러 서버 측 모델에 도달하면 null을 지정합니다. datetime을 매핑하고 구문 분석 할 수 없으므로.
값 입력 및 kendo.parseDate의 노력의 일부 console.log 출력. 21/01/2015 0000 Wed 1 월 21 일 2015 00:00:00 GMT + 0000 (GMT 표준시)
다음은 내 클라이언트 측 유효성 검사입니다. 그렇다면 유효성 검사가 클라이언트 측에서 작동하도록하려면 어떻게해야합니까? kendo.parseDate의 형식과 문화 매개 변수를 지정
$("#accidentForm").kendoValidator({
rules: {
date: function (input) {
if (input.is("[name=Accident.IncidentDate]")) {
console.log(input.val());
var d = kendo.parseDate(input.val());
console.log(d);
return d instanceof Date;
}
return true;
}
},
messages: {
customRuleDateTimePick: "Incident date time format incorrect."
}
});
// attach a validator to the container and get a reference
var validatable = $("#accidentForm").kendoValidator().data("kendoValidator");
$("#btnSave").click(function() {
//validate the input elements and check if there are any errors
if (validatable.validate() === false) {
// get the errors and write them out to the "errors" html container
var errors = validatable.errors();
$(errors).each(function() {
$("#errors").html(this);
});
return false;
}
return true;
});
나는 형식적인 옵션과 문화로 kendo.parseDate를 사용하여 그것을 해결했다고 생각합니다. – richardb