[Javascript] IE onclick problem

Claude Schneegans schneegans at internetique.com
Wed Apr 16 20:38:35 CDT 2008


 >>Yes,
but how do you hadle it, -how do you capture the bolean response
of true or false in case it fails to run, or in casse it succeeded, how
do you check it prior to invoking other instuctions?
 
Well, you don't "capture the bolean response", the browser takes care of it.
When an event handler returns, the event is passed to the next event 
handler for the event.
This is called bubbling, but if an event returns false, the process is 
stopped.
Since all onsubmit events are processed before the submit itself, if one 
of them
returns false, the submit is actually not executed.
Ex:
<FORM NAME="myForm"....... onsubmit="return checkMyForm()">
................
</FORM>
<SCRIPT>
function checkMyForm()
    {
    if (<any invalid value in a field>)
        {
        alert("There is an invalid value in one field");
        return false;
        }
    return true;
    }
</SCRIPT>

if there is an invalid field, the function displays the message, returns 
false, and the submit is cancelled,
otherwise, the form is submitted normally.




More information about the Javascript mailing list