I have an Event create form which accepts input for addition to an Access database. Initially I used Spry validation but decided to change to validation with Javascript. The validation code works perfectly, but I can't figure out how to get the insert to the database and redirect code (genrated by Dreamweaver) to execute.
Here is the code behind the submit button:
<form id="form2" name="form2" method="post" action="">
<input name="submit" type="submit" id="submit2" onclick="return MM_callJS('submitForm()')"
value="Submit" />
</form>
<div id="submit">
Here is the JavaScript code:
<script type="text/javascript" language="javascript">
function submitForm()
{
if (document.eventAdd.classif
ication.se
lectedInde
x == "0")
{
alert("Event Classification is Required");
document.eventAdd.classifi
cation.foc
us();
return false;
}
if (document.eventAdd.eventTi
tle.value == "")
{
alert("Event Title is Required");
document.eventAdd.eventTit
le.focus()
;
return false;
}
if (document.eventAdd.startMo
nth.select
edIndex == "0")
{
alert("Start Month is Required");
document.eventAdd.startMon
th.focus()
;
return false;
}
if (document.eventAdd.startDa
y.selected
Index == "0")
{
alert("Start Day is Required");
document.eventAdd.startDay
.focus();
return false;
}
if (document.eventAdd.endMont
h.selected
Index == "0")
{
alert("End Month is Required");
document.eventAdd.endMonth
.focus();
return false;
}
if (document.eventAdd.endDay.
selectedIn
dex == "0")
{
alert("End Day is Required");
document.eventAdd.endDay.f
ocus();
return false;
}
document.eventAdd.submit()
;
}
</script>
When it tries to execute the submit statement, I get the error message: "Object doesn't support this property or method". I also tried "return true" but that doesn't do anything.
The for worked perfectly before I added validation and when I was usig Spry valiation. Is it possible to initiate the insert/redirect code from JavaScript, and if so, how is i done?
Start Free Trial