piers
07-22-2009, 06:12 AM
I'm very new to javascript and I'm trying to write some code for an input field that only permits the user to continue if the link they are inputting is valid..
So far I have this:
function goToPage() {
var url;
var pswd;
pswd = this.document.pswdform.pswdinput.value;
loc = "folder/" + pswd + "/" + pswd + ".html"
if (pswd != "validlink1") {
alert("\nPlease enter a valid link")
return false;
}
else fetchit(loc);
}
}
function fetchit(loc) {
var root;
window.location.href = loc;
}
and the mark up;
<form name="pswdform" action="javascript:goToPage(this)"><p><input class="form_element_textfield" name="pswdinput" value="" size="20"><br /><br /><a class="button" href="javascript:goToPage(this.form);" onclick="this.blur();"><span>Submit Link</span></a>
But I can't get it to work... has anyone got any suggestions? Thanks!
So far I have this:
function goToPage() {
var url;
var pswd;
pswd = this.document.pswdform.pswdinput.value;
loc = "folder/" + pswd + "/" + pswd + ".html"
if (pswd != "validlink1") {
alert("\nPlease enter a valid link")
return false;
}
else fetchit(loc);
}
}
function fetchit(loc) {
var root;
window.location.href = loc;
}
and the mark up;
<form name="pswdform" action="javascript:goToPage(this)"><p><input class="form_element_textfield" name="pswdinput" value="" size="20"><br /><br /><a class="button" href="javascript:goToPage(this.form);" onclick="this.blur();"><span>Submit Link</span></a>
But I can't get it to work... has anyone got any suggestions? Thanks!