onsubmit="someFunction()"
Calls a function
onsubmit="JavaScript:someFunction()"
The same, but with a completely useless label. The person who wrote it probably saw a javascript:
scheme URL in an href
attribute (which is a terrible idea unless you are explicitly writing a bookmarklet) and fell into a cargo cult, not understanding that on*
attributes expect their values to be JavaScript and not a URL.
onsubmit="return someFunction()"
The same, but the submit event handler function returns whatever the function returns. If it returns false
it prevents the default behaviour of the form submission.
I couldn't find any mention of the onsubmit attribute in any HTML5 form docs
It is defined in general terms here.
Should I not use it?
Intrinsic event attributes violate the principle of separation of concerns and have some really unintuitive scoping rules while also depending on the functions called from them to be globals.
They are best avoided.
Modern JS would bind the event handler using addEventListener
and prevent the default behaviour of the form submission with preventDefault
Would it be better to use onclick on the submit button?
No. Form submission can be triggered through other mechanisms, such as pressing enter in a text input. While this might trigger a click event on the submit button, it is better to say what you mean.