onDateChange(event: any): void {
const inputDate = event.target.value; // Get the value from the input
// Convert to Date object
const date = new Date(inputDate);
// Validate if the date is valid
if (this.isValidDate(date)) {
// Call your function if the date is valid
console.log("Valid date:", date);
this.someFunction();
} else {
console.log("Invalid date");
}
}
isValidDate(date: Date): boolean {
return !isNaN(date.getTime()); // Returns false if the date is invalid
}
someFunction(): void {
// Your custom logic here
}