Serendipity,
The easiest way, in my experience, is not to use a submit button.
Instead, use a regular
<input type="button" value="Submit" onclick"this.form.submit();"> . The script gives the necessary submit action.
Thus, the only way to submit the form should be for the user to click the "Submit" button (or to hit enter if/when it has focus).
I used to be sure that this technique was universally true, but you should test the latest crop of browsers to make sure. I could be out of date.
The slight downside is that
<form ...... onsubmit="....."> (should you need it) will now not intercept the submission, but the workaround is also simple; modify the "Submit" button's
onclick"this.form.submit();" to make submission conditional or whatever you would otherwise put in the form's
onsubmit . If it gets complex, then write/call a function.
Here is a demo which you can use to do some testing:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Airshow :: Untitled</title>
<style type="text/css">
form { margin-top:20px; padding:12px; width:150px ; border:1px solid #999; }
</style>
<script>
function writeInputText(){
document.f1.i1.value = 'ABCDEF';
document.f2.i1.value = 'ABCDEF';
}
onload = function(){
setTimeout("writeInputText()", 1000);
}
</script>
</head>
<body>
<form name="f1" action="">
<input name="i1" value="------"><br>
<input><br>
<input type="radio" name="x" value="1"><br>
<input type="radio" name="x" value="2"><br>
<input type="radio" name="x" value="3"><br>
<input type="button" value="My Submit" onclick="this.form.submit();"><br>
</form>
<form name="f2" action="">
<input name="i1" value="------"><br>
<input><br>
<input type="radio" name="x" value="1"><br>
<input type="radio" name="x" value="2"><br>
<input type="radio" name="x" value="3"><br>
<input type="Submit" value="HTML Submit"><br>
</form>
</body>
</html>
Airshow