you would need to code this your self.
you would need to capture the ID's of the records being deleted, look them up in the dependent table and display the message if they exist.
Your code for the cancel will only work if the name of the button is "Cancel" if it is not working, it means you are using a different name for the cancel button.