To restrict user from adding a future date in shipment receiving date. The field should be either today or any past date but not future.
The below validation function that is executed when a field is changed by a user or client call.
function validateField(context) {
var curRec = context.currentRecord;
var fieldName = context.fieldId;
if (fieldName === 'date') { //replace "date" with your field id
var recDate = curRec.getValue({fieldId: fieldName});
var today = new Date();
if (recDate > today){
alert('You cannot enter a future date');
curRec.setValue({
fieldId: 'date',
value: null
});
}
return true;
}