form validation using JavaScript

<html>
<head>
<title>Form Validation</title>
<script>

function validate()
{
var b=document.frm1.txtEmail.value;
var len=b.length;
var a='@';
var dot='.';
var valid1,valid2;

//form validation for First Name

if(document.frm1.txtFirstName.value=="")
{
alert("The First Name is Empty");
document.frm1.txtFirstName.focus();
return false;
}

// form validation for Last Name

else if(document.frm1.txtLastName.value=="")
{
alert("The Last Name is Empty");
document.frm1.txtLastName.focus();
return false;
}

//form validation for Gender
else if(document.frm1.optGender[0].checked==false && document.frm1.optGender[1].checked==false)
{
alert("Check for the Gender option");
return false;
}

//form validation for Phone no
else if(document.frm1.txtPhone.value=="")
{
alert("The Phone no field is Empty");
document.frm1.txtPhone.focus();
return false;
}

//for checking numbers in Phone no field
else if(isNaN(document.frm1.txtPhone.value))
{
alert("Please enter the valid numbers");
document.frm1.txtPhone.focus();
return false;
}

//validation for Comment
else if(document.frm1.txtcomment.value=="")
{
alert("The comment field is empty");
document.frm1.txtcomment.focus();
return false;
}

//validation for Email
else if(document.frm1.txtEmail.value=="")
{
alert("The Email field is empty");
document.frm1.txtEmail.focus();
return false;
}

//validation for correct email
else if(b!="")
{
for(var i=0;i<=len;i++)
{
if(b.charAt(0)!=a)
{
if(b.charAt(i)==a)
valid1=true;
if(b.charAt(i)==dot)
{
valid2=true;
}
}
else
{
alert("EnterValidEmail address");
document.frm1.txtEmail.focus();
}
}
if(valid1!=true || valid2!=true)
{
alert("Please enter the valid email");
document.frm1.txtEmail.focus();
return false;
}
}

}
</script>
</head>

<body>
<form name="frm1">
<table border=1 align="center">
<tr align>
<td>First name:</td>
<td colspan=2><input type="textbox" name="txtFirstName"></td>
</tr>
<tr align>
<td>Last name:</td>
<td colspan=2><input type="text" name="txtLastName"></td>
</tr>
<tr align="center">
<td>Gender:</td>
<td><input type="radio"name="optGender">Male</td>
<td><input type="radio" name="optGender">Female</td>
</tr>
<tr align="center">
<td>Phone no:</td>
<td colspan=2><input type="text" name="txtPhone"></td>
</tr>
<tr align="center">
<td>Email:</td>
<td colspan=2><input type="text" name="txtEmail"></td>
</tr>
<tr align="center">
<td>Comments:</td>
<td colspan=2><input type="textarea" name="txtcomment" row=5 col=3></td>
</tr>
<tr align="center">
<td colspan=3><input type="submit" value="Submit" onclick="return(validate())"></td>
</tr>
</table>
</form>
</body>
</html>