I'm quite new at JS. I'm not exactly getting what's the difference between
<form onsubmit="return func()"> and <form onsubmit="func()">
. Both the cases are doing the same thing. What is the job of return & when do we need that?
You are better off to have something like this
<form id="submit-btn">
Then for the javascript
document.getElementById("submit-btn").addEventListener("click", func);
function func() {
//Stuff Here
}
It is just cleaner, but as for your question. Really they do perform the same thing. It just depends if the output of your function is a boolean value (true or false) if you type return func() and it is a false value then the form will not submit. If you type func() then no matter the output the form will be submitted.