petey,
the only problem with your suggestion is that if someone wants to manually call:
...somewhere in the javascript, the form's onsubmit event does not fire.
Of course, this is where Jeff's hidden submit button could come in handy. It would have to be named, but the user could code this instead:
Code:
formName.submitButton.click();
...and this WOULD fire the form's onsubmit event.
Consider this short example:
Code:
<html>
<head>
</head>
<body>
<form name='formName' onsubmit='return confirm("submit?");'>
<input type='submit' name='submitButton' /><br />
hitting enter in this field submits form:<input type='text' size='30' /><br />
<input type='button' value='manual submit' onclick='formName.submit();' /><br />
<input type='button' value='send click() to submit button' onclick='formName.submitButton.click()' />
</form>
</body>
</html>
Hitting the first button:
type='submit'
...triggers the onsubmit event.
Hitting the 'enter' key with focus in the text field triggers the onsubmit event.
Pressing the next button
type='button' onclick='formName.submit()'
...does
NOT trigger the onsubmit event.
Pressing the last button
type='button' onclick='formName.submitButton.click()'
...once again
DOES trigger the onsubmit event.
So it just depends on how one wants to go about it.
--Dave