Matt wrote:
When the user click the submit button in myform.asp, then it will
invoke the
javascript to check the form data. I want to know if we need
document.myform.submit(); ?? Because even I comment it out,
formresponse.asp
could still get the form data.
//myform.asp
<script type="text/javascript">
function checkformdata()
{ //etc...
document.myform.submit();
}
</script>
<form name="myform" action="formresponse.asp" method="post"
onsubmit="checkformdata()">
//controls etc...
</form>
//formresponse.asp
<%= Request.Form %>
Using submit() is only for when you want to submit something through a
different means. Say, for instance, you want an anchor link to submit a
form. You can set onClick="document.myform.submit()".
When the onSubmit callback is called, it is called either because
someone pressed the submit button, or submit() was called.
Note that you should return something from your function, and return it
to the onSubmit handler. Returning true tells the form to keep going,
but returning false tells the form not to send. For instance, you might
do something like this:
<script type="text/javascript">
function checkFormData()
{
// etc...
if(dataValid)
return true;
else
{
alert("You are a naughty boy");
return false;
}
}
<FORM ... onSubmit="return checkFormData()">
Brian