Setting window location with a form
Code:
<html>
<head>
<script>
function validURL(url)
{
if ((url == "") || (url == "http://"))
return false;
return true;
}
function submitIt(form)
{
if (validURL(form.urlname.value))
window.location = form.urlname.value
else
{
alert("Please type a URL");
return false;
}
}
</script>
</head>
<body>
<form onSubmit="return submitIt(this)" name="form1" method="post">
URL: <input name="urlname" type="text" value="http://">
<input type="submit" value="Go">
</form>
</body>
</html>
This code doesn't work, not sure why. What's wrong?