Page Submits twice

U

Umesh

Hi

Here is the sample code for my form, but problem is that it submits
twice in some cases when i click submit 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" value="save">
</form>


Can any one help me?
 
S

Steve Belanger

Even though your question has to do with Javascript and this is an HTML
group, here's something that might help you.

Get rid of the onsubmit parameter on the form.

Use it on the button itself, like this:

<input type="button" onclick="validateform()" name="save" id="save"
value="save">

Now inside the function itself, if the form is set to be submitted, do this
just before the return true line:

document.abc.submit();


Hope this helps.
Steve.
 
H

Hywel Jenkins

Even though your question has to do with Javascript and this is an HTML
group, here's something that might help you.

"Anything goes here. For anal HTML-only chat try CIWAH."
Get rid of the onsubmit parameter on the form.
Pourquoi?

Use it on the button itself, like this:

<input type="button" onclick="validateform()" name="save" id="save"
value="save">

Now inside the function itself, if the form is set to be submitted, do this
just before the return true line:

document.abc.submit();

That's nuts. The OP now has a form that *won't* submit if JavaScript is
enabled.

The OP hasn't helped himself by failing to provide the appropriate code.
The snippet he gave is useless. It like saying "I can't get a good
picture on my TV. I've got a black cable and a blue one."
 
A

Alan J. Flavell

Even though your question has to do with Javascript and this is an HTML
group, here's something that might help you.

Translation: "beware of off-topic answers, which would likely be
disputed if only they appeared in an appropriate group".
 

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,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top