How to by-pass a function that depends on datepicker if a user does not choose a date

How to by-pass a function that depends on datepicker if a user does not choose a date

I have set up a function that determines a date depending on what date the user chooses in the datepicker. Currently if the user does not choose a date it still runs this function as if the default date is today, what can i do so that it does not run this function if no value is chosen in the datepicker?