# Validating using Java

**URL:** <https://forums.knack.com/t/validating-using-java/8358>\
**Category:** Get Answers\
**Created:** [August 28, 2020, 6:33pm UTC](https://forums.knack.com/t/validating-using-java/8358 "2020-08-28T18:33:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SalBanuelo34423](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/salbanuelo34423/32/258_2.png) [@SalBanuelo34423](https://forums.knack.com/u/SalBanuelo34423)\
**Post date:** [August 28, 2020, 6:33pm UTC](https://forums.knack.com/t/validating-using-java/8358/1 "2020-08-28T18:33:07Z")

</div>

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 :)&nbsp;

&nbsp;

//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;  
}  
})  
});
