Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Page Submits Twice

Reply
Thread Tools

Page Submits Twice

 
 
Umesh
Guest
Posts: n/a
 
      02-24-2006
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?

 
Reply With Quote
 
 
 
 
Paxton
Guest
Posts: n/a
 
      02-24-2006

Umesh wrote:
> 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.

 
Reply With Quote
 
 
 
 
Umesh
Guest
Posts: n/a
 
      02-24-2006
Any way! thanks for suggestion

 
Reply With Quote
 
dNagel
Guest
Posts: n/a
 
      02-25-2006
<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>
 
Reply With Quote
 
Umesh
Guest
Posts: n/a
 
      02-25-2006
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.

 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      02-25-2006
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
....

;-}

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
One click on a form submits twice! Ken Adams HTML 4 01-22-2013 05:47 PM
document.write submits page David Williams Javascript 1 10-18-2007 05:23 PM
Page Submits twice Umesh HTML 3 02-24-2006 08:10 PM
What can I do while javascript submits the page?? charlie_M Javascript 6 09-23-2005 01:39 PM
newbie question on multiple submits in page jpf Javascript 0 04-22-2004 03:15 PM



Advertisments