> returnValue= true;
This sets the value of the global variable returnValue
to true and has got nothing to do with your issue.
> e.returnValue = true;
This sets the return value of the event to ' true
' and is a MS only property. So your onclick
returns false
if the validation fails and thereby prevents form submission.
> e.preventDefault()
This cancels / prevents the default action caused by the event. In our case, the click action submits the form which is prevented by calling p reventDefault().
It is important to notice that both e.returnValue = false;
and e.preventDefault()
in our case achieve the same purpose(of cancelling the forum submission) for different browser types.