Hello everyone,
I know zilch about javascript. If its not a cut-n-past script I’m pretty much SOL.
So, this may seem like a very simple question, but I cant’ figure out how to validate my form fields through my submit link.
Here is my validate code:
[code=php]
<script language=”JavaScript” type=”text/javascript”>
<!–
function checkForm(theForm)
{
if (theForm.firstname.value == “”)
{
alert(“Please enter a value for the “firstname” field.”);
theForm.firstname.focus();
return (false);
}
if (theForm.lastname.value == “”)
{
alert(“Please enter a value for the “lastname” field.”);
theForm.lastname.focus();
return (false);
}
if (theForm.username.value == “”)
{
alert(“Please enter a value for the “username” field.”);
theForm.username.focus();
return (false);
}
if (theForm.email.value == “”)
{
alert(“Please enter a value for the “email” field.”);
theForm.email.focus();
return (false);
}
if (theForm.password.value == “”)
{
alert(“Please enter a value for the “password” field.”);
theForm.password.focus();
return (false);
}
if (theForm.password.value != theForm.confirm.value)
{
alert(“The two passwords are not the same.”);
theForm.confirm.focus();
return (false);
}
}
//–>
</script>
and my form / submit link looks like this right now:
[code=php]
<form method=”post” action=”register.php” onsubmit=”return checkForm(this)” language=”JavaScript” name=”register”>
<a href=”javascript:document.register.submit()” class=”nav”>Register</a>
</form>
Hopefully someone will understand what I’m trying to say and accomplish. Don’t laugh at me too hard if this is the dumbest question to be asked thus far ?
Thanks for your help. It is greatly appreciated!
Cheers,
Dave