Link to home
Start Free TrialLog in
Avatar of j_machale
j_machale

asked on

Stop the submit action

I have a Perl Script that writes out a HTML form  and some javascript functions. The functions(behind the submit button) check if the form details have been filled out correctly or not. If the function fails (e.g. bad details) I want to cancel the POST rather than requery my Perl Script. Can anyone tell me how to do this ? T.I.A.
ASKER CERTIFIED SOLUTION
Avatar of Paul Maker
Paul Maker
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of j_machale
j_machale

ASKER

Adjusted points from 50 to 60
Sorry makerp , I need a little more help as this does not seem to stop the POST. My code outline is as follows

<form name="frmHolidays" action="$script" method="POST" onSubmit()="return checkForm(this)">
......
<input type="submit" value="Continue" name="cmdConfirm" tabindex="1"  
<input type="reset" value="Clear Form" name="cmdClear">
.......
<SCRIPT LANGUAGE="JavaScript">

function checkForm(myobj) {
return false;
}

This code will still requery the script. Do I have the right idea ?
put the script in the head of the html ..
i.e

<HEAD>
<SCRIPT LANGUAGE="JavaScript">
 function checkForm(myobj)
 {
      return false;
 }
</SCRIPT>
</HEAD>

youir onsubmit should be

onSubmit="return checkForm(this)"

not

onSubmit()="return checkForm(this)"

lose the brackets after onSubmit
 

Cheers makerp, I didn't need to move the JS it was just the () after the onSubmit !!!. Thanks.

P.S. There were in your original code
whoops .. sorry