I have some doubt in my mind that if a jsp page onclick() calls a JavaScript method.
I have two scenarios
onclick="return validatePage();"onclick="validatePage();"
What is the difference between these two types calling of JavaScript methods.
On the first, by returning the return value of the function, you will cancel the default action for the event when the function returns false. Similar to calling event.preventDefault(). It is notably used when checking for forms validity, where returning false will cancel the form submission.
ps. In the case of form validation, instead of binding the validation function a button's onclick, you should attach it to the form's onsubmit event. This way if the user triggers the submit through pressing Enter on an input, the form will still be checked before submitting.
preventDefault and stopPropagation. I'll update the answer to reword the "cancel" statement.If you return false from the javascript function ,onclick = "return validatePage();" wont submit the form values.
where as, in the case of onclick = "validatePage();" will submit the form values even if you return false from the Javascript function.