To enable or disable the submission of form in jscript

How to stop the submission of form in jscript coding?

CAF controls circumvent the standard html form submission process (to
ensure that async commands and commands triggered by elements other than
submit buttons are processed the same as submit buttons).

To prevent the form from submitting, you can return any value from
the button’s onclick handler


(ex: "var foo = true; if (foo) return;". 
To allow it to submit, don't return anything (ex "var foo = false; if 
(foo) return;"

There are a couple of other CAF-specific hooks. You can attach a
client-side action listener to any command control; action listeners are
called after the form is validated but before it is submitted. You can
prevent the form from submitting by returning false from the action
listener; the following script (which you’d add via a ScriptBlock
control) will allow the command with an id of “myCommandId” to submit
only if foo is true:


CAF.model('#{activePageBean.clientIds['myCommandId']}').addActionListener(function(id) 
{ 
var foo = bar; 
return (foo); 
}); 

thank u very much mimel.