submit question

M

Matt

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 %>
 
H

Hywel Jenkins

Matt said:
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>

checkformdata() should return false if the validation fails, and true if
it succeeds. There'll be no need for the document.myform.submit();
then, but your onsubmit should be
onsubmit="return checkformdata()"

Of course, you should be validating the form on the server, where you
know the environment.
 
M

Mark Parnell

Of course, you should be validating the form on the server, where you
know the environment.

Nothing wrong with validating it client side as well, though. For most
users it will save a bit of time and bandwidth.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top