3.2.0

javascript ignored

Hi I have this code that completely ignores the javascript in the form. Here's the code:

<html>
<head>
<title>Rocky Mountain Choice Foods Registration</title>

<SCRIPT LANGUAGE="JavaScript">

function checkAll()
{
var why = "";
why += checkBlank(document.theForm.fullname.value, "a name");
why += checkBlank(document.theForm.address.value, "an address");
why += checkBlank(document.theForm.city.value, "a city");
why += checkBlank(document.theForm.state.value, "a state");
why += checkZIP(document.theForm.zip.value);
why += checkEmail(document.theForm.email.value);
why += checkPhone(document.theForm.phone.value);
why += checkBlank(document.theForm.username.value, "a username");
why += checkPassword(document.theForm.password.value);
why += checkBlank(document.theForm.passwordconf.value, "a password confirmation");
why += checkPassComp(document.theForm.password.value, theForm.passwordconf.value);

if(why != "")
{
alert(why);
return false;
}

return true;
}

function checkBlank(strng, fill)
{
var error = "";

if(strng == "")
{
error = "You didn't enter " + fill + ".\n";
}

return error;
}

function checkZIP(field)
{
var valid = "0123456789-";
var hyphencount = 0;

if (field.length!=5 && field.length!=10)
return "Please enter a valid zip code.\n";

for(var i=0; i < field.length; i++)
{
temp = "" + field.substring(i, i+1);
if(temp == "-") hyphencount++;
if(valid.indexOf(temp) == "-1")
return "Please enter a valid zip code.\n";
if((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-"))
return "Please enter a valid zip code.\n";
}

return "";
}

function checkEmail(field)
{
var error = "";
var emailFilter=/^.+@.+\..{2,3}$/;
var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/;

if(!(emailFilter.test(field)))
error = "Please enter a valid email address.\n";
else if (field.match(illegalChars))
error = "The email address contains illegal characters.\n";

return error;
}

function checkPhone(field)
{
var error = "";
var stripped = strng.replace(/[\(\)\.\-\ ]/g, '');

//strip out acceptable non-numeric characters
if(isNaN(parseInt(stripped)))
error = "The phone number contains illegal characters.\n";
else if (!(stripped.length == 10))
{
error = "The phone number is the wrong length.
Make sure you included an area code.\n";
}

return error;
}

function checkPassword(strng)
{
var error = "";

if(strng == "")
return "You didn't enter a password.\n";

var illegalChars = /[\W_]/; // allow only letters and numbers
if((strng.length < 6) || (strng.length > 8))
{
error = "The password is the wrong length.\n";
}
else if(illegalChars.test(strng))
{
error = "The password contains illegal characters.\n";
}

return error;
}

function checkPassComp(p1, p2)
{
var error = "";

if(!p1.equals(p2))
error = "The passwords don't match.";

return error;
}

</script>

</head>

<body>

<h4>Rocky Moutain Choice Foods Registration</h4>
<form name="theForm" onSubmit="return checkAll()" action="registerConf.php" method="post">
<table border="0">
<tr>
<td>Full Name:</td>
<td><input type="text" name="fullname"></td>
</tr>
<tr>
<td>Address Line 1:</td>
<td><input type="text" name="addr1"></td>
</tr>
<tr>
<td>Address Line 2:</td>
<td><input type="text" name="addr2"></td>
</tr>
<tr>
<td>City:</td>
<td><input type="text" name="city"></td>
</tr>
<tr>
<td>State:</td>
<td><input type="text" name="state"></td>
</tr>
<tr>
<td>Zip:</td>
<td><input type="text" name="zip"></td>
</tr>
<tr>
<td>Email:</td>
<td><input type="text" name="email"></td>
</tr>
<tr>
<td>Phone Number</td>
<td><input type=text name="phone" maxlength="13"></td>
</tr>
<tr>
<td>Username:</td>
<td><input type="text" name="username"></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="text" name="password"></td>
</tr>
<tr>
<td>Confirm Password:</td>
<td><input type="text" name="passwordconf"></td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>

</body>
</html>
Brian
September 23,

This topic is archived.

See also:


Back to support forum