Brief overview, have three functions that return boolean for the zip code and email format and another to check if two fields are not empty and contain the same value. The wrapper functions I made that use another function to write to a div.innerHTML work fine. The function I made to check them all and then to call the 3 individual wrapper functions doesnt respond at all. FF Error Console reports nothing and IE does not alert anything either. I don't know what is wrong. If anyone can take a look at the code and tell me where I am doing something wrong or try to run it in your own browser? Any help is very much appreciated.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Test Form Checker</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="generator" content="HAPedit 3.1">
<script type="text/javascript">
function isValidZip(value) {
var re = /^\d{5}([\-]\d{4})?$/;
return (re.test(value));
}
function validEmail(str){
return ((str.indexOf(".",str.indexOf("@")) - str.indexOf("@") > 1) && (str.indexOf("@") == str.lastIndexOf("@")) && (str.indexOf("@") > 0 && str.lastIndexOf(".") < str.length - 1))
}
function isPassword(x,y) {
return (x != "" && x == y)
}
function writeTo(x){
M = document.getElementById("dumpHere");
M.innerHTML+=x+"<br />"
return true;
}
function testZip(v) {
if (isValidZip(v)){
writeTo("Valid Zip Code Format!");
return true;
}
writeTo("Not a valid zip code format!!!");
return true;
}
function testEmail(v){
if (validEmail(v)){
writeTo("Valid E-mail Format");
return true;
}
writeTo("Not valid email format!!!");
return false;
}
function checkPass(){
if (isPassword(document.getElementById("input3").value,document.getElementById("input4").value)){
writeTo("Password Good!!!!");
return true
}
writeTo("Password not valid, enter a value and matching value to confirm!!!")
return true
}
function testForm() {
if (validEmail(document.getElementById("input2").value) && isValidZip(document.getElementById("input1").value) && isPassword(document.getElementById("input3").value,document.getElementById("input4").value)){
writeTo("Form Ready to Submit!!!");
return true;
}
isValidZip(document.getElementById('input1').value);
isValidEmail(document.getElementById('input2').value);
checkPass();
return true
}
</script>
</head>
<body bgcolor="#FFFFFF">
<hr />
<input type="text" id="input1"><br />
<input type="text" id="input2"><br />
<input type="text" id="input3"><br />
<input type="text" id="input4"><br />
<input type="button" value="Is Input1 zipcode?" onclick="testZip(document.getElementById('input1').value);"><br />
<input type="button" value="Is Input2 email?" onclick="testEmail(document.getElementById('input2').value);"><br />
<input type="button" value="Is Input3 and Input4 same?" onclick="checkPass();"><br />
<input type="button" value="Check" onlick="testForm()"><br />
<div id="dumpHere"></div>
</body>
</html>
I wish I that I would get an error or something, but this literally shows me nothing. Maybe someone here can identify where I went wrong with it.