Page Submits Twice

U

Umesh

Hi

Here is the sample code for my form, but problem is that it submitts
twice in some cases when i click sub mit button.


<script>
function validateform (){
//do a lot validation here, if validation failes, return false;

//finaly this line
return true;
}
</script>

<form name="abc" action="any other apge" onsubmit = "return
validateform();">



<input type="submit" name="save" id="save">
</form>

Can any one help me?
 
P

Paxton

Umesh said:
Hi

Here is the sample code for my form, but problem is that it submitts
twice in some cases when i click sub mit button.


<script>
function validateform (){
//do a lot validation here, if validation failes, return false;

//finaly this line
return true;
}
</script>

<form name="abc" action="any other apge" onsubmit = "return
validateform();">



<input type="submit" name="save" id="save">
</form>

Can any one help me?

You need to ask this in a javascript forum. It's a client side problem
- ASP is purely server side.

/P.
 
D

dNagel

<script>
var isSubmitted = false;
function validateform (){
//do a lot validation here, if validation failes, return false;
//finaly this line
if (!isSubmitted)
isSubmitted=true;
return true;
else
return false;
}
</script>

<form name="abc" action="any other apge" onsubmit = "return validateform();">
<input type="submit" name="save" id="save">
</form>
 
U

Umesh

Hi ! Thanks for your time.

I am not able to understand why this probelm occured. can u elaborate
more.

**Note submit button is clicked only once.
 
E

Evertjan.

dNagel wrote on 25 feb 2006 in microsoft.public.inetserver.asp.general:
if (!isSubmitted)
isSubmitted=true;
return true;
else
return false;

=== Do not forget the {}

....
if (!isSubmitted) {
isSubmitted=true;
return true;
}
else
return false;
....

=== why use "else":

....
if (!isSubmitted) {
isSubmitted=true;
return true;
}
return false;
....

=== why use an "if":

....
var x = isSubmitted
isSubmitted = true
return !x
....

;-}
 

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

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,135
Latest member
VeronaShap
Top