Connecting Tech Pros Worldwide Forums | Help | Site Map

Return false does not stop the submit action.

Newbie
 
Join Date: Jan 2007
Posts: 2
#1: Jan 8 '07
I am currently working on the asp.net web project. I using the return false method to stop the submit action when the user choose to cancel the action.
It is working fine before I am installing the FlashGet Version 1.80.1002.

After install the FlashGet program, the page will still submitted even I put the return false in the code. Is anyone hit this problem before? Any solutions for this?

Thank you.

Sample Code:

<html xmlns="http://www.w3.org/1999/xhtml" >
<head><title>
Untitled Page
</title></head>
<body>
<form name="form1" method="post" action="Default2.aspx" id="form1">
<div>
</div>

<div>
<input type="submit" name="Button1" value="Button" onclick="return false;" id="Button1" />
</div>

<div>
</div></form>
</body>
</html>

acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#2: Jan 8 '07

re: Return false does not stop the submit action.


Try
Expand|Select|Wrap|Line Numbers
  1. <form name="form1" method="post" action="Default2.aspx" id="form1" onsubmit="return false;">
instead.
Newbie
 
Join Date: Jan 2007
Posts: 2
#3: Jan 9 '07

re: Return false does not stop the submit action.


Let said I want to create a popup message box with ok and cancel button. When User click on Ok Button, it will proceed to the action. If the user click cancel, the popup will disapear without refresh the page. Before that, I am using Onclick=return true/false to control. Can I know if I am using the onsubmit method, how to cater the scenario above?
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#4: Jan 9 '07

re: Return false does not stop the submit action.


Quote:

Originally Posted by leos1981

Let said I want to create a popup message box with ok and cancel button. When User click on Ok Button, it will proceed to the action. If the user click cancel, the popup will disapear without refresh the page. Before that, I am using Onclick=return true/false to control. Can I know if I am using the onsubmit method, how to cater the scenario above?


function confirmed(form) {
return confirm("Are you sure you want to delete");
}


.....
onSubmit = "return confirmed(this)">
Reply