Is there anyone can give me a sample on how to check a URL is bad link or not?

Can't Post

I have a form to let the user to input a URL. After the user input the URL, he can click on a button named TestURL to check whether the URL can be visited correctlly, that is to say, to find out whether it is a bad link or not. Anyone one can give me some example or clue to implement it? Thanks a lot.