pookypook
03-23-2009, 02:44 AM
I have a form that calls a javascript function to validate a date:
<form name="frmSelect" method="Post" action="allxml.asp" onSubmit="return ValidateForm()">
the function is called if I only have a little bit of code like this:
<script language="javascript">
function ValidateForm()
{
alert("matchArray = null");
}
</script>
but once I add all of the code the validation doesn't run.
any Ideas what the problem could be?
thanks
part of my code:
<?xml version="1.0" encoding="UTF-16"?>
<html>
<head>
<title>Time </title>
<script language="javascript">
function ValidateForm()
{
var dteDate;
var day, month, year;
dt=document.frmSelect.txtDate.value;
var datePat = /^(\d{1,2})(\/)(\d{1,2})(\/)(\d{4})$/;
var matchArray = dt.match(datePat);
if (matchArray == null){
alert("matchArray = null");
return false;
}
month = matchArray[1];
day = matchArray[3];
year = matchArray[5];
month--;
dteDate=new Date(year,month,day);
if((day==dteDate.getDate()) && (month==dteDate.getMonth()) && (year==dteDate.getFullYear()))
return true;
alert("invalid date - day " +day+" month " +month+" year "+ year);
return false
}
</script>
</head>
<body>
<form name="frmSelect" method="Post" action="allxml.asp" onSubmit="return ValidateForm()">
<form name="frmSelect" method="Post" action="allxml.asp" onSubmit="return ValidateForm()">
the function is called if I only have a little bit of code like this:
<script language="javascript">
function ValidateForm()
{
alert("matchArray = null");
}
</script>
but once I add all of the code the validation doesn't run.
any Ideas what the problem could be?
thanks
part of my code:
<?xml version="1.0" encoding="UTF-16"?>
<html>
<head>
<title>Time </title>
<script language="javascript">
function ValidateForm()
{
var dteDate;
var day, month, year;
dt=document.frmSelect.txtDate.value;
var datePat = /^(\d{1,2})(\/)(\d{1,2})(\/)(\d{4})$/;
var matchArray = dt.match(datePat);
if (matchArray == null){
alert("matchArray = null");
return false;
}
month = matchArray[1];
day = matchArray[3];
year = matchArray[5];
month--;
dteDate=new Date(year,month,day);
if((day==dteDate.getDate()) && (month==dteDate.getMonth()) && (year==dteDate.getFullYear()))
return true;
alert("invalid date - day " +day+" month " +month+" year "+ year);
return false
}
</script>
</head>
<body>
<form name="frmSelect" method="Post" action="allxml.asp" onSubmit="return ValidateForm()">