I have two Date Pickers inside a grid "Start Date" and "End Date".I am trying to validate these dates on edit and want to show only one validation message any time. Everything works fine except one scenario.
Steps that creates a problem:
1. Select a date for Start Date (ex. 1/1/2015) and select a date for End Date (ex. 2/1/2015). Everything is fine. I can save the record successfully.
2. Now change the Start date to 3/1/2015 and validation popsup as expected. Change the end date to 4/1/2015 so that its greater then Start Date. Validation message disappears as expected.
3. Now if I try to Save, I get 1/1/2015 as the value on my server side code, not 3/1/2015.
$("StartDate").value() -- this has 3/1/215
$("#grid").data("kendoGrid").dataSource.view() - this has startdate as 1/1/2015 which is wrong.
If I don't have the validation, everything works fine. What is causing this behavior? Please help.
My validation logic:
dateValidation:
function
(input){
if
((input.is(
"[name='StartDate']"
) || input.is(
"[name='EndDate']"
)) && input.val() !=
""
)
{
$(
"div.k-invalid-msg[data-for='StartDate']"
).hide();
$(
"div.k-invalid-msg[data-for='EndDate']"
).hide();
var
startDate =
new
Date($(
"#StartDate"
).val());
var
endDate =
new
Date($(
"#EndDate"
).val());
if
(endDate < startDate)
return
false
;
else
return
true
;
}
return
true
;
}