AECPFeedback AECPFeedback

How can I override the check_form function in javascript?

Discussion created by AECPFeedback AECPFeedback on Jun 9, 2015
Latest reply on Jan 3, 2018 by Sarika Tandale
CE 6.5.4
I'm trying to override the check_form function in: /include/javascript/sugar_3.js with my own.

I've read this post:
overriding Save button : after ajax validation save editView form
It was a lot of help but apparently she left some critical stuff out.

As it is, if I click the Save button it should just show me an alert saying 'Test' and not save the record.
Instead it just saves the record.   

How can I make this work?   

I added a file:  custom/modules/Contacts/js/CkContactTaken.js
<code>
function ckContactTaken()
{
    alert("Test");
    return false;   
}

function check_form(formname)
{
    bValid = false;
    if(typeof(siw)!='undefined'&&siw&&typeof(siw.selectingSomething)!='undefined'&&siw.selectingSomething) return false;
    bValid = validate_form(formname,'');
    if(!bValid) return false;
   
    if(!ckContactTaken()) return false;
   
    return true;   
}
</code>

I added another file to try to get CE to 'load' my js file:
custom/modules/Contacts/metadata/editviewsdef.php
<code>
$viewdefs['Contacts']['EditView']['templateMeta']['includes'] =
    array (
        array (
        'file' => 'custom/modules/Contacts/js/CkContactTaken.js',
        ),
    );
</code>

Outcomes