Validating using Java

we are trying tot validate a filed suing the following Java but is not working, can some one take a look and tell me what are we doing wrong? Thanks a lot :) 

 

//Validation of the Collection Date and Delivery Date fields
$(document).on('knack-view-render.view_116', function(event, view, data) {
$("#view_116 .kn-button").on("click", function() {
//if the collection date is less than the delivery date and the collection time is
//less than or equal to the delivery time returns true
if($("#view_116-field_176 .kn-getDate()").val() < ("#view_116-field_177 .kn-getDate()") &&
$("#view_116-field_176 .kn-getHours()").val() <= ("#view_116-field_177 .kn-getHours()")){
confirm("1.-Correct date");
return true;
} //if the date is the same and the collection time is greater than or equal to the delivery time
//return false
else if($("#view_116-field_176 .kn-getDate()").val() == ("#view_116-field_177 .kn-getDate()") &&
$("#view_116-field_176 .kn-getHours()").val() >= ("#view_116-field_177 .kn-getHours()")){
alert("2.-The time of the collection date cannot be greater than the time of the delivery date");
return false;
}
//if the collection date is greater than the delivery date, it returns a false
else if($("#view_116-field_176").val() > ("#view_116-field_177")){
alert ("3.-The delivery date must be after the collection date");
return false;
}
else{
alert ("4.-The delivery time must be after the collection time");
return false;
}
})
});