verify webpage
Posted: Mon Jun 27, 2011 3:23 pm
I have an input field that has verification of correct url, but I would also like it to check to make sure that the site is online. what I have currently is very simple...
but like I said, I would like to add that when the blur function is called it will check to make sure that the link in the input box is a valid page and not returning a 404 error or something like that. Any ideas or help would be greatly appreciated. Thank you in advance.
Code: Select all
function isURL() {
var url = document.getElementById("webpage_url");
var urlerr = document.getElementById("url_error");
var reg = /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/;
if(!reg.test(url.value)) {
urlerr.innerHTML = "Invalid WebPage Address";
url.focus();
} else {
urlerr.innerHTML = "<img src='custom/modules/CT221_SEP_test/js/images/good.png' style='margin-left: 140px; margin-top: -35px;' />";
}
}
YAHOO.util.Event.on("webpage_url", "blur", isURL);