What is the difference between “someFunction()”, “JavaScript:somFuction()”, and “return someFunct()” in form onsubmit attribute?

I’m wondering the differences are between calling a JavaScript function in these different ways from a form.

Method 1

<form onsubmit="someFunction()">

Method 2

<form onsubmit="JavaScript:someFunction()">

Method 3

<form onsubmit="return someFunction()">

I couldn’t find any mention of the onsubmit attribute in any HTML5 form docs (only a little info on some HTML4 docs). Should I not use it? Would it be better to use onclick on the submit button?

Answer

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.