To cancel a form submission, the onSubmit function should return a false value. You need to use the following command:
function onSubmit() { return false; }