Hello! There is something wrong in the code below. What is it? Can you help me please? The form validation was working just fine when I added the last 'if' for zip code validation. The function didn't work and returned true. The code is:
Code:
<script type="text/javascript">
function validateForm()
{
var y=document.forms["form"]["firstname"].value;
var f=document.forms["form"]["zipcode"].value;
var x=document.forms["form"]["email"].value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if (y==null || y=="NAME")
{
alert("First name must be filled out");
return false;
}
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
{
alert("Not a valid e-mail address");
return false;
}
}
var re='/(^\d{5}$)/';
if (f!=re)
{
alert ("Not a valid address");
return false;
}
}
</script>
Any ideas or advice? Thank you in advance!