Hi all,
I was wondering if anyone would be willing to look over my code to tell me what I am doing wrong? I am creating a webpage for when users type in thier room number it links them to specific pages in the intranet.. But it doesnt seem to be going anywhere when I type in the room number and click submit.. So I think I am coding wrong somewhere in the <form> section of my code… If can look it over and let me know what I might have done wrong I would be most appreciated.. Thank you!
<HTML>
<HEAD>
<TITLE>Untitled Page</TITLE>
<META http-equiv=”Content-Type” content=”text/html; charset=utf-8″>
<SCRIPT LANGUAGE=”JavaScript”>
function validateroom(field) {
var valid = “0123456789-“;
var hyphencount = 0;
if (!field.macth(/^[d]{4}$/)) {
alert(“Invalid characters in your room number.”);
return false;
}
//This will allow the user to enter only 4 numbers…
for (var i=0; i < field.length; i++) {
temp = “” + field.substring(i, i+1);
if (temp == “-“) hyphencount++;
if (valid.indexOf(temp) == “-1”) {
alert(“Invalid characters in your room number. Please try again.”);
return false;
}
if ((hyphencount > 1) || ((field.length==10) && “”+field.charAt(5)!=”-“)) {
alert(“The hyphen character should be used with a properly formatted 4 digit room humber, like ‘1234’. Please try again.”);
return false;
}
}
return true;
if(roomnumber>1200 && roomnumber<1800)
{
location.href=”
}
//repeat it for others…
}
if(roomnumber>2200 && roomnumber<2800)
{
location.href=”
}
//repeat it for others…
}
if(roomnumber>3200 && roomnumber<3800)
{
location.href=”
}
//repeat it for others…
}
// End –>
</script>
</HEAD>
<form name=room onSubmit=”return validateroom(this.room.value)”>
Room #: <input type=text size=5 name=room>
<input type=submit value=”Submit” onClick=”validateroom(this.room.value)”>
</form>
</BODY>
</HTML>