[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1638
  • Last Modified:

HTML Form - javaScript - stop from submitting!

I have a form that onSubmit should perform some javascript functions, but I want to stop the form from actually submitting anywhere.

I've tried return false to no avail - any other ideas?

<script type="text/javaScript">
function killFunction(){
      return false;
}
</script>
<form name="thisInputForm" onSubmit="submitAjaxForm(this,'clientDashRecentActivity','clientDash/recentActivity.asp','activeMembersExclusions');killFunction();return false;">

0
trickyidiot
Asked:
trickyidiot
1 Solution
 
raj3060Commented:
it should be called like:

onSubmit = "return YourFunction()"

and YourFunction() should return false if you don't want your form to be submitted.
0
 
numbers1to9Commented:
Try using the attribute "action" and leave its "value" empty, like: action=" ".

Return false should work, I think, try putting it in the form attribute using onclick, like: onclick="return false".
0
 
raj3060Commented:
call all the functions inside killFunction() like this:

<script type="text/javaScript">
function killFunction(n){
submitAjaxForm(n,'clientDashRecentActivity','clientDash/recentActivity.asp','activeMembersExclusions');
return false;
}
</script>

<form name="thisInputForm" onSubmit="return killFunction(this);">
0
 
BogoJokerCommented:
Does submitAjaxForm eventually do something like: form.thisInputForm.submit()?  If there is any call to form.submit() it is likely that is what is submitting the form.  I do not know of a way to stop that javascript call from stopping the form.  However the methods listed above should be working otherwise.

- Joe P
0
 
scrathcyboyCommented:
You will find that AJAX is the problem here, without it your script will terminate at the first return false, but with the AJAX framework, it is so complex, that it is almost impossible to debug as to where execution stops.  So to solve the problem, do not use the AJAX calls at all.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now