Stop Save action on condition

Hello Developers,

How can I stop “Save” action on condition in custom js?

I have write if condition and in condition I declared “return false” if condition not match. but it still save the records.

Help highly appreciate.
Thanks.

Use a before save logichook.

Insert this code in your condition:

SugarApplication::appendErrorMessage('End Date must be after Start Date');
$queryParams = array(
                'module' => 'Accounts',
                'action' => 'EditView',
                'record' => $recordId,
            );
SugarApplication::redirect('index.php?' . http_build_query($queryParams));