My java script of validation is not working don't know why
here is the code
Header php file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" type="text/css" href="c.css" />
<title>simple document</title>
<script src="validate.js;cart.js">
</script>
<script type=" text/javascript">
<?php
session_start();
?>
</script>
</head>
<body>
<div align="center" class="none" style=" width: 100%;">
<table class="none" width="100%">
<tr>
<td>
<img src="images/main_banner.jpg" height="150"/><br/>
</td>
<td>
<?php
$s=$_SESSION['id'];
if($s==null)
{
echo'
<form name="login" action="login_check.php" method="post">
<table class="none" border="2px solid" style="height: 150px; width: 100px;">
<tr>
<td width="40px">
UserName:
</td>
<td width="40px">
<input class="login" type="text" name="user" />
</td>
</tr>
<tr>
<td width="40px">
Password:
</td>
<td width="40px">
<input class="login" type="password" name="pass" />
</td>
</tr>
<tr>
<td>
<input class="login" value="Login" type="submit" name="login" />
</td>
<td>
<a class="none" style="color:black; font-weight: bold ;" href="reg.php">Register</a>
</td>
</tr>
</table>
</form>';
}
else
{
echo '<div><h4>Welcome '.$_SESSION['Name'] .'</h4></div><br/>';
echo '<a href="logout.php">Logout</a>';
}
?>
</td>
</tr>
</table>
</div>
<br/>
<div align="justify" width="80%">
<table>
<tr>
<td>
<a href="home.php">Home</a>
</td>
<td>
<a href="kids.php">Kids Wear</a>
</td>
<td>
<a href="mens.php">Mens Wear</a>
</td>
<td>
<a href="women.php">Women Wear</a>
</td>
</tr>
</table>
</div>
SCRIPT
function req(field,alertmsg)
{
with(field)
{
if(value==null||value=="")
{
alert(alertmsg);
return false;
}
else
{
return true;
}
}
}
function compare(field1,field2)
{
var val1
var val2;
with(field1)
{
val1=value;
}
with(field2)
{
val2=value;
if(val1!=val2)
{
alert(" Do not Match ");
return false;
}
else
{
return true;
}
}
}
function validate(thisform)
{
with(thisform)
{
if(req(un,"User name must be filled")==false)
{
un.focus();return false;
}
if(req(pass,"Enter the Password")==false)
{
pass.focus();return false;
}
if(req(pass1,"Enter the Password again")==false)
{
pass1.focus();return false;
}
if(req(credit,"Cerdit Card Number must be filled")==false)
{
credit.focus();return false;
}
if(req(email,"Valid Email-ID must be filled")==false)
{
email.focus();return false;
}
if(req(email1,"Enter Email-ID again")==false)
{
email1.focus();return false;
}
if(req(name,"Name filled cannot be Empty")==false)
{
name.focus();return false;
}
if(req(add,"Address must be filled")==false)
{
add.focus();return false;
}
if(req(city,"City must be filled")==false)
{
city.focus();return false;
}
if(req(pin,"Pin Code must be filled")==false)
{
pin.focus();return false;
}
if(req(state,"State must be filled")==false)
{
state.focus();return false;
}
if(req(coun,"Country must be filled")==false)
{
coun.focus();return false;
}
if(req(mob,"Phone number must be filled")==false)
{
mob.focus();return false;
}
if(compare(email,email1)==false)
{
email1.focus(); return false;
}
if(compare(pass,pass1)==false)
{
pass1.focus(); return false;
}
}
}
REGISTRATION PAGE
<?php
$title = "Welcome";
include ("head.php");
?>
<br/>
<form action="register.php" method="post" onsubmit="return validate(this)">//here where i call it
<div class="none" align="center" style="width: 80%;">
<table class="reg" style="font-weight: bold;">
<tr>
<td>
User Name:
</td>
<td>
<INPUT class="reg" TYPE="text" NAME="un">
</td>
</tr>
<tr>
<td>
Password:
</td>
<td>
<INPUT class="reg" TYPE="password" NAME="pass">
</td>
</tr>
<tr>
<td>
Confirm Password:
</td>
<td>
<INPUT class="reg" TYPE="password" NAME="pass1">
</td>
</tr>
<tr>
<td>
Cerdit Card No:
</td>
<td>
<INPUT class="reg" TYPE="text" NAME="credit">
</td>
</tr>
<tr>
<td>
Email-Id:
</td>
<td>
<INPUT class="reg" TYPE="text" NAME="email">
</td>
</tr>
<tr>
<td>
Confirm Email-Id:
</td>
<td>
<INPUT class="reg" TYPE="text" NAME="email1">
</td>
</tr>
<tr>
<td>
Full Name:
</td>
<td>
<INPUT class="reg" TYPE="text" NAME="name">
</td>
</tr>
<tr>
<td>
Address:
</td>
<td>
<INPUT class="reg" TYPE="text" NAME="add">
</td>
</tr>
<tr>
<td>
City:
</td>
<td>
<INPUT class="reg" TYPE="text" NAME="city">
</td>
</tr>
<tr>
<td>
PinCode:
</td>
<td>
<INPUT class="reg" TYPE="text" NAME="pin">
</td>
</tr>
<tr>
<td>
State:
</td>
<td>
<INPUT class="reg" TYPE="text" NAME="state">
</td>
</tr>
<tr>
<td>
Country:
</td>
<td>
<INPUT class="reg" TYPE="text" NAME="coun">
</td>
</tr>
<tr>
<td>
Phone Number:
</td>
<td>
<INPUT class="reg" TYPE="text" NAME="mob">
</td>
</tr>
<tr></tr>
<tr>
<td align="center">
<input class="button" type="reset">
</td>
<td align="center">
<input class="button" type="submit" value="Submit">
</td>
</tr>
</table>
</div>
</form>
</body>
</html>