Why isn't my validation in HTML working?please help.So frustrated?

Anon

New member
I cant get my validation to work.Its meant to validate the information put into the text boxs is the correct format and if it is then its supposed to go to a page that says thank you for registring,but when i click submit it just goes to the page even if the details are wrong.Also my reset button wont work?Any ideas?
And thanks so much in advance!



function validate()
{

document.getElementById("lblFnameVal").innerHTML="";
var isValidlogin="true";
var checkForX = document.getElementById("fname").value.indexOf("visitor");

document.getElementById("lblpass").innerHTML="";
var isValidpass="true";
var passw = document.getElementById("fpass").value.indexOf("password");

document.getElementById("lblmail").innerHTML="";
var isValidemail="true";
var emaily = document.getElementById("fmail").value.indexOf("@");
var emailer = document.getElementById("fmail").value.indexOf( ".");


if (emaily == "@" && emailer=="." )
{ isValidemail=="true";
}
else
{
isValidemail=="false";
}

if(checkForX == -1 || checkForX.length <5 || checkForX.length >7 )
{
document.getElementById("lblFnameVal").innerHTML="not valid";
document.getElementById("lblFnameVal").style.color="red";
isValidlogin="false";
}


if(emaily == -1 || emaily.length <1 || emaily.length >30 || emailer == -1 || emailer.length <1 || emailer.length >30)
{
document.getElementById("lblmail").innerHTML="not valid";
document.getElementById("lblmail").style.color="red";
isValidemail="false";
}

if(passw == -1 || passw.length <5 || passw.length >17 )
{
document.getElementById("lblpass").innerHTML="not valid";
document.getElementById("lblpass").style.color="red";
isValidpass="false";
}

if(isValidpass =="true" && isValidlogin=="true" && isValidemail=="true")
{

document.getElementById("myForm").submit();

}

}

</script>

</head>


<body>

<div id="container">
<div id="header">
<img src = "./Images/banner.jpg" title="home" alt="homepage">


</div>
<div id="navblock">
<div id="navcontainer">
<ul>


<li><a href="./registration.html">Registration</a></li>
<li><a href="./login.html">Login</i></a></li>
</ul>
</div>
</div>


<div id ="left">

<ul>
<li><a href="registration.html">Register</a>
<li><a href="login.html">Login </a>

<li>Login</li>


</ul>


</div>

<div id="mid" >
<p>
<div id="midcontents">


<br>
<form name="aForm" id ="myForm" action="process_registration.html" method="get">



<input type="reset" value="Reset">
<input type="submit" value="submit" onclick="validate()">
<input type = "hidden" name = "secret"value="X">


<address>First name:&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp <input type="text" name="fname" id="fname" value="" size="20" maxlength="20">&nbsp <label id="lblFnameVal">*</label></address>
</form>

<p>
<form name="passForm" id ="mypassForm" action="href=process_registration.html" method="get">

<address>Password: &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp <input type="password" name="fpass" id="fpass" value="" size="20" maxlength="20"> &nbsp <label id="lblpass">*</label></address>
</form>

<p>
<form name="mailForm" id ="mymailForm" action= "process_registration.html" method="get">

<address>Email: &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp <input type="text" name="fmail" id="fmail" value="" s ize="20" maxlength="20">&nbsp <label id="lblmail">*</label></address>





</form>
 
Back
Top