How to tell if a function is being called by javascript?
JavaScript cannot directly call a PHP function. If you think that JS may be 'triggering' the call of that validation handler, then there must be an AJAX event going out to the backend, which then calls the validation handler. If that is the case, the request will go out to the system/ajax URI on your site (unless it has been intentionally changed to a different URI - you can double check this by viewing the 'Network' tab in Google Chrome's developer tools), which will then handle the request and dispatch it to the validation handler. 

So...

You can check the $_GET['q'] value in your validation handler:

if ($_GET['q'] == 'system/ajax') {
    // AJAX request
}
else {
    // other request
}