okay i, trying to validate a form… but the javascript is doing absolutely NOTHING!
[code=html]
function checkform()
{
if (document.register.username.value == ”) {
alert (“Please enter your desired username!”);
return false;
}
if (document.register.firstname.value == ”) {
alert (“Please enter your first name!”);
return false;
}
if (document.register.password.value == ”) {
alert (“Please enter your desired password!”);
return false;
}
if (document.register.email.value == ”) {
alert (“Please enter your email address!”);
return false;
}
return checkmail();
if (function checkmail(false)){
alert (“Invalid Email address!”);
return false;
}
}
function checkmail()
{
var x = document.register.email.value;
var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
if (filter.test(x)) return true;
else return false;
}
that is my validator.js
and in my html file i have this in the head:
[code=html]<script language=”JavaScript” src=”validator.js” type=”text/javascript”></script>
my form name is register and the onsubmit is “return checkform();”
also could you help me getting the email validator do work, i wasnt sure how to make an if statement that if a function returned false then somthing happens….