You can filter for a valid URL format using a regular expression, as the following:
^(?:http(?:s)*|ftp)://[a-zA-Z0-9\.\-]+(?:\:\d{1,5})?(?:[A-Za-z0-9\.\;\:\@\&\=\+\$\,\?\-/]|%u[0-9A-Fa-f]{4}|%[0-9A-Fa-f]{2})*$
I found the original regexp at msdn but I’ve extended it with one more character: "-" in the "virtual dir" section and have made the first group shorter.


